Χρήστης:Geraki/monobook.js
Από τη Βικιπαίδεια, την ελεύθερη εγκυκλοπαίδεια
Σημείωση: Μετά την αποθήκευση πρέπει να καθαρίσετε την προσωρινή μνήμη του browser σας για να δείτε τις αλλαγές: Mozilla: πατήστε Reload (ή Ctrl-R), IE / Opera: Ctrl-F5, Safari: Cmd-R, Konqueror Ctrl-R.
// This will add an [edit top] link at the top of all pages except preview pages // by User:Pile0nades // Add an [edit top] link to pages addOnloadHook(function () { // if this is preview page or generated page, stop if(document.getElementById("wikiPreview") || window.location.href.indexOf("/wiki/Special:") != -1) return; // get the page title var pageTitle = document.title.split(" - ")[0].replace(" ", "_"); // create div and set innerHTML to link var divContainer = document.createElement("div"); divContainer.innerHTML = '<div class="editsection" style="float:right;margin-left:5px;margin-right:15px;margin-top:3px;">[<a href="/w/index.php?title='+pageTitle+'&action=edit§ion=0" title="'+document.title.split(" - ")[0]+'">επεξεργασία εισαγωγής</a>]</div>'; // insert divContainer into the DOM before the h1 if(window.location.href.indexOf("&action=edit") == -1) document.getElementById("content").insertBefore(divContainer, document.getElementsByTagName("h1")[0]); if(window.location.href.indexOf("&action=edit§ion=0") != -1) document.getElementById("wpSummary").value = "/* Intro */ "; }); // addPurge addOnloadHook( function (){ var x = document.getElementById('ca-history'); if(!x) return; if(x.children) x = x.children[0].href; else x = x.childNodes[0].href; addLink("p-cactions", x.replace(/=history/, "=purge"), 'εκκαθάριση', 'ca-purge', 'Purge the internal cache for this page', 0); }); function replace() { var s = prompt("Αναζήτηση regexp?"); if(s) { var r = prompt("Αντικατάσταση regexp?"); if(!r && r != '') return; var txt = document.editform.wpTextbox1; txt.value = txt.value.replace(new RegExp(s, "g"), r); } } addOnloadHook(function () { if(document.forms.editform) { addLink('p-cactions', 'javascript:replace()', 'αντικατ.', 'ca-replace', 'Regexp replace for the edit window', '', 'ca-history'); } }); function addLink(where, url, name, id, title, key, after){ //* where is the id of the toolbar where the button should be added; // i.e. one of "p-cactions", "p-personal", "p-navigation", or "p-tb". // //* url is the URL which will be called when the button is clicked. // javascript: urls can be used to do more complex things. // //* name is what will appear as the name of the button. // //* id is the id of the button; it's best to define one. // Use a prefix to make sure its unique. Optional. // //* title is the tooltip title that gives a longer description // of the button; if you define a accesskey, mention it here. Optional. // //* key is the char you want for the accesskey. Optional. // //* after is the id of the button you want to follow this one. Optional. // 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; } document.write('<script type="text/javascript" src="' + 'http://el.wikipedia.org/w/index.php?title=User:Geraki/popups.js' + '&action=raw&ctype=text/javascript&dontcountme=s"></script>'); popupAdminLinks=true; popupFixDabs=true; if (mwCustomEditButtons) { mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://upload.wikimedia.org/wikipedia/en/c/c8/Button_redirect.png", "speedTip": "Ανακατεύθυνση", "tagOpen": "#REDIRECT [[", "tagClose": "]]", "sampleText": "Κείμενο"}; }; if (mwCustomEditButtons) { mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://upload.wikimedia.org/wikipedia/commons/b/b4/Button_category03.png", "speedTip": "Κατηγορία", "tagOpen": "[[Κατηγορία:", "tagClose": "|{{PAGENAME}}]]", "sampleText": "Κείμενο"}; }; if (mwCustomEditButtons) { mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://upload.wikimedia.org/wikipedia/commons/9/9e/Btn_toolbar_gallery.png", "speedTip": "Έκθεση", "tagOpen": "<gallery>", "tagClose": "</gallery", "sampleText": "Κείμενο"}; }; if (mwCustomEditButtons) { mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://upload.wikimedia.org/wikipedia/commons/7/79/Button_reflink.png", "speedTip": "Παραπομπή", "tagOpen": "<ref>", "tagClose": "</ref>", "sampleText": "Παραπομπή"}; mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://upload.wikimedia.org/wikipedia/commons/a/a0/Button_references_alt.png", "speedTip": "Ενότητα παραπομπών", "tagOpen": "<references />", "tagClose": "", "sampleText": ""} }; function nichalp_articleFromURL(h) { if (typeof h != 'String') h=String(h); h=decodeURI(h); var m=RegExp('[^:]*://el\\.wikipedia\\.org/(wiki/|w/index\\.php\\?title=)([^&?]*)').exec(h); if(m===null) return null; return m[2]; } function nichalp_isIpUser(user) { return RegExp('(Χρήστης:)?' + '((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\.){3}' + '(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])') .test(user); } function nichalp_removeAnchor(article) { // is there a #? if not, we're done var i=article.indexOf('#'); if (i == -1) return article; return article.substring(0,i); } function nichalp_userName(article) { var i=article.indexOf('Χρήστης'); var j=article.indexOf(':'); if (i != 0 || j == -1) return null; var k=article.indexOf('/'); if (k==-1) return article.substring(j+1); else return article.substring(j+1,k); } // do it function nichalp_customLinks() { addPurge(); var article=nichalp_articleFromURL(document.location.href); if (!article) return; var user=nichalp_userName(article); if(!user) return; user=nichalp_removeAnchor(user); if (!nichalp_isIpUser(user)) { addToolboxLink('http://tools.wikimedia.de/~kate/cgi-bin/count_edits?user='+user+'&dbname=elwiki_p', "Αριθμός edits του "+user, 'toolbox_katestool'); } var special='http://el.wikipedia.org/w/index.php?title=Special:'; addToolboxLink(special + 'Log&user='+user, "Μητρώο "+user, 'toolbox_userlog'); addToolboxLink(special + 'Blockip&ip='+user, 'Φραγή '+user, 'toolbox_blockuser'); addToolboxLink(special + 'Special:Ipblocklist&action=unblock&ip='+user, 'Αποφραγή '+user, 'toolbox_unblockuser'); } // make it all happen on page load if (window.addEventListener) window.addEventListener("load",nichalp_customLinks,false); else if (window.attachEvent) window.attachEvent("onload",nichalp_customLinks); else { window._old_nichalp_onload = window.onload; window.onload = function() { window._old_nichalp_onload(); nichalp_customLinks(); } } function addToolboxLink(url, name, id){ var tb = document.getElementById('p-tb').getElementsByTagName('ul')[0]; addlilink(tb, url, name, id); } function addlilink(tabs, url, name, id, title, key){ 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); 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; }