User:Biyan-to/monobook.js

/* */ // define  custom buttons (id, class, popup title, image src, width, height, alt text, onClick and parameters) var wikEdButton = []; wikEdButton[100] = ['wikEdDiv', 'wikEdButton', 'Make the selection a html DIV element', 'http://upload.wikimedia.org/wikipedia/commons/6/67/WikEd_logo.png', '16', '16', 'DIV', 'javascript:WikEdEditButton(this, this.id, null, TestHandler);' ]; wikEdButton[101] = ['wikEdTest', 'wikEdButton', 'This is a test button', 'http://upload.wikimedia.org/wikipedia/commons/0/07/WikEd_disabled.png', '16', '16', 'Test', 'javascript:WikEdEditButton(this, this.id, null, TestHandler);' ];

// define custom button bars (id outer, class outer, id inner, class inner, height, grip title, button numbers) var wikEdButtonBar = []; wikEdButtonBar['custom1'] = ['wikEdButtonBarCustom1', 'wikEdButtonBarCustom1',  'wikEdButtonsCustom1',  'wikEdButtonsCustom1',  44, 'My custom buttons', [ ] ];//100, 'br', 101] ]; wikEdButtonBar['custom2'] = ['wikEdButtonBarCustom2', 'wikEdButtonBarCustom2',  'wikEdButtonsCustom2',  'wikEdButtonsCustom2',  44, 'My custom buttons', [ ] ];//100, 'br', 101] ];

// define the function which is called upon clicking the custom button

function TestHandler(obj) {

// select the appropriate text change target (whole, selection, cursor, focusWord, focusLine, selectionWord, or selectionLine) //  focus... is the text under the cursor; ...Word and ...Line extend the target to the start/end of the word or line WikEdGetText(obj, 'selection, cursor'); if (obj.selection.plain != '') { obj.changed = obj.selection; } else { obj.changed = obj.cursor; }

// make the changes to the plain target text

// remove the previously added formatting if ( /&lt;div&gt;(.*?)&lt;\/div&gt;/i.test(obj.changed.plain) ) { obj.changed.plain = obj.changed.plain.replace(/&lt;div&gt;(.*?)&lt;\/div&gt;/gi, '$1'); }

// add the text formatting else { obj.changed.plain = '&lt;div&gt;' + obj.changed.plain + '&lt;/div&gt;'; obj.changed.plain = obj.changed.plain.replace(/(&lt;div&gt;)( *)(.*?)( *)(&lt;\/div&gt;)/, '$2$1$3$5$4'); }

// keep the changed text selected, needed to remove the formatting with a second click obj.changed.keepSel = true;

return; }

// install User:Pilaf/Live_Preview page preview tool mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:Pilaf/livepreview.js' + '&action=raw&ctype=text/javascript');

// installation of the wikEd editing page extension //wikEdLoadRegExTypoFix = true; // install User:Cacycle/wikEd international English example translation mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:Cacycle/wikEd_international_en.js' + '&action=raw&ctype=text/javascript');

// install User:Cacycle/wikEd editing page extension mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:Cacycle/wikEd.js' + '&action=raw&ctype=text/javascript');

// include scripts from other pages from User:Quarl/monobook.js function winc(s) { document.write(' '); }

// loads each tool after loading the page

window.onload = function Main { // addLink('p-personal', '/wiki/User:Cacycle/monobook.css', 'monobook.css', 'pt-monobookcss', 'monobook.css', , ); addLink('p-personal', '/wiki/User:Cacycle/monobook.js', 'monobook.js',  'pt-monobookjs',  'monobook.js', , ); addLink('p-personal', '/wiki/User:Cacycle/wikEd', 'wikEd',  'pt-monobookjs',  ' ', , ); addLink('p-personal', '/wiki/User_talk:Cacycle/wikEd', 'wikEd talk',  'pt-monobookjs',  ' ', , ); addLink('p-personal', '/wiki/User:Cacycle/wikEd_help', 'wikEd help',  'pt-monobookjs',  ' ', , ); addLink('p-personal', '/wiki/User:Cacycle/wikEd.js', 'wikEd.js',  'pt-monobookjs',  ' ', , ); addLink('p-personal', '/wiki/User:Cacycle/wikEd_development', 'wikEd dev',  'pt-monobookjs',  ' ', , ); addLink('p-personal', '/wiki/User_talk:Cacycle/wikEd_development', 'wikEd dev talk',  'pt-monobookjs',  ' ', , ); addLink('p-personal', '/wiki/User:Cacycle/wikEd_dev.js', 'wikEd_dev.js',  'pt-monobookjs',  ' ', , ); if (document.getElementById('ca-edit')) { document.getElementById('ca-edit').firstChild.innerHTML = 'edit'; } }

// Live Preview User:Pilaf/livepreview.js wpUserName  = 'Cacycle'; // User name to display in signatures wpShowImages = true;     // Enable downloading and displaying of images

// User:Lupin's crazy navigation popups User:Lupin/popups.js // (http://en.wikipedia.org/wiki/Wikipedia:Tools#Navigation_popups) popupDelay = 0; popupHideDelay = 0.2; popupAdminLinks = true; popupFixRedirs = true; popupFixDabs = true; popupStructure = 'original' imagePopupsForImages=false; popupModifier='ctrl' ; winc('User:Lupin/popupsdev.js');

/* // Wikipedia:WikiProject_User scripts/Scripts/Twinkle (WP:TW) importScript('User:AzaToth/morebits.js'); importScript('User:AzaToth/twinklefluff.js'); importScript('Wikipedia:WikiProject User scripts/Scripts/Add LI menu'); importStylesheet('Wikipedia:WikiProject User scripts/Scripts/Add LI menu/css'); importScript('User:AzaToth/twinklewarn.js'); importScript('User:AzaToth/twinklearv.js'); importScript('User:AzaToth/twinklespeedy.js'); importScript('User:AzaToth/twinklediff.js'); importScript('User:AzaToth/twinkleprotect.js'); importScript('User:AzaToth/salt.js');

//Begin Unwatch function

$(function { var query_prefix = "title=Special:Watchlist&action=submit&remove=1&id[]="; //var query_prefix = "action=unwatch&title=";

if (window.location.href.indexOf("Special:Watchlist") == -1) return; var links = document.getElementById('content').getElementsByTagName('a'); for (var i = 0; i < links.length; i++) { if (links[i].href.substring(links[i].href.length-15) != '&action=history') continue; var unwatch = document.createElement('a'); unwatch.href = "/w/index.php?" + query_prefix + encodeURIComponent(links[i].title); unwatch.title = "Unwatch "+links[i].title; unwatch.appendChild(document.createTextNode("unwatch")); links[i].parentNode.insertBefore(unwatch, links[i].nextSibling); // kluge to handle case where "diff" is unlinked: var delim = links[i].previousSibling; delim = (delim.nodeType == 3 ? delim.nodeValue : ""); links[i].parentNode.insertBefore(document.createTextNode(delim.replace(/^.*diff/, "")), unwatch); } });

// End Unwatch function

// a helper function to add extra navigation links, from User:Trilobite/Tools and WikiProject User scripts/Scripts/Add LI link // winc('User:Cacycle/monobook.js/addlink.js'); // from User:Omegatron/monobook.js/addlink.js function addLink(where, url, name, id, title, key, after) { var na = document.createElement('a'); na.href = url; na.appendChild(document.createTextNode(name)); var li = document.createElement('li'); if (id) { li.id = id; } li.appendChild(na); var tabs = document.getElementById(where).getElementsByTagName('ul')[0]; if (after) { tabs.insertBefore(li,document.getElementById(after)); } else { tabs.appendChild(li); } if (id) { if (key && title) { ta[id] = [key, title]; }   else if (key) { ta[id] = [key, '']; }   else if (title) { ta[id] = ['', title]; } } // re-render the title and accesskeys from existing code in wikibits.js  akeytt; return li; }

/* */