User:JP06035/monobook.js
From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Mozilla/Safari: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Internet Explorer: press Ctrl-F5, Opera/Konqueror: press F5.
//<pre> // This is based on the original code on Wikipedia:Tools/Editing tools // // The original code was on the project page and needed to be cut and paste to the user's // monobook.js page. However, this caused problems with the quote marks. So I have moved // it to its own page. // // I do not know a lot about Javascript so please do not ask for a complicated change //Interiot's javascript edit counter if (document.title.indexOf('User:Interiot/Tool2/code.js') != -1) { document.write('<script type="text/javascript" src="' + 'http://en.wikipedia.org/w/index.php?title=User:Interiot/Tool2/code.js' + '&action=raw&ctype=text/javascript&dontcountme=s"></script>'); } function InsertButtonsToToolBar() { tooly = document.getElementById('toolbar'); if (tooly != null) { StrikeTextButton = "<a href=\"javascript:insertTags('<s>','</s>','Insert text here');\"><img src=\"http://upload.wikimedia.org/wikipedia/en/c/c9/Button_strike.png\" alt=\"Strike\" title=\"Strike-through text\"></a>"; SupportVoteImageButton = "<a href=\"javascript:insertTags('* [[Image:Symbol support vote.png|15px]] '''Support.'''','','');\"><img src=\"http://upload.wikimedia.org/wikipedia/commons/thumb/5/5b/Symbol_support_vote.png/15px-Symbol_support_vote.png\" alt=\"Support\" title=\"Support vote\"></a>"; OpposeVoteImageButton = "<a href=\"javascript:insertTags('* [[Image:Symbol oppose vote.png|15px]] '''Oppose.'''','','');\"><img src=\"http://upload.wikimedia.org/wikipedia/commons/thumb/5/5b/Symbol_oppose_vote.png/15px-Symbol_oppose_vote.png\" alt=\"Oppose\" title=\"Oppose vote\"></a>"; NeutralVoteImageButton = "<a href=\"javascript:insertTags('* [[Image:Symbol neutral vote.png|15px]] '''Neutral.'''','','');\"><img src=\"http://upload.wikimedia.org/wikipedia/commons/thumb/5/5b/Symbol_neutral_vote.png/15px-Symbol_neutral_vote.png\" alt=\"Neutral\" title=\"Neutral vote\"></a>"; } } window.onload = InsertButtonsToToolBar; 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; } function addTab(url, name, id, title, key){ var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0]; return addlilink(tabs, url, name, id, title, key); } addOnloadHook(function() { if (document.title.search("/") != -1 || document.title.search("- History -") != -1) { //no subpages or history return; } if (document.title.indexOf("User:") == 0) { username_a = document.URL.match(/:.*:(.*)/); username=username_a[1]; addTab("http://en.wikipedia.org/w/index.php?title=User_talk:" + username + "&action=edit§ion=new", "+", "", "Add new comment to user page.", ""); addTab("http://en.wikipedia.org/wiki/Special:Contributions/" + username, "contribs", "ca-contrib", "Contribs", ""); addTab("http://en.wikipedia.org/w/index.php?title=Special%3ALog&type=move&user=" + username, "page moves", "ca-pagemoves", "Page moves", ""); addTab("http://en.wikipedia.org/wiki/User:Interiot/Tool2/code.js?username=" + username, "Edit count", "", "Edit count", ""); } }); addOnloadHook(function () { for (var i=0; i<document.links.length; ++i) { if (document.links[i].href.indexOf('Special:Watchlist')>0) { document.links[i].href+='?hideOwn=1'; break; } } }); function addForceSummary() { if(!/&action=edit/.test(window.location.href) && !/&action=submit/.test(window.location.href)) return; if(/§ion=new/.test(window.location.href)) return; if(!document.forms.editform) return; document.forms.editform.wpSave.onclick = forceSummary; } function forceSummary() { if(!document.forms.editform.wpSummary.value.replace(/^(?:\/\\*.*\\*\/)? *(.*) *$/,'$1')) { var r = prompt('Are you sure you want to submit without adding a summary?\nTo add a summary, type it in the box below:',document.forms.editform.wpSummary.value); if(r == null) { return false; } document.forms.editform.wpSummary.value = r; } return true; } addOnloadHook(addForceSummary); // 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&section=0" title="'+document.title.split(" - ")[0]+'">edit top</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 */ "; }); gsTimeInsertBefore = ''; // leave blank to append after "logout" // function makeTime() { var li = document.createElement( 'li' ); li.id = 'pt-time'; var mySpan = document.createElement( 'span' ); mySpan.appendChild( document.createTextNode( '00:00:00' ) ); li.appendChild( mySpan ); if ( ! gsTimeInsertBefore ) { // append to end (right) of list document.getElementById( 'pt-logout' ).parentNode.appendChild( li ); } else { var before = document.getElementById( gsTimeInsertBefore ); before.appendChild( li, before ); } doTime = window.setTimeout("getTime()", 1000); } addOnloadHook( makeTime ); function getTime() { var time = new Date(); var hours = time.getUTCHours(); if (hours < 10) { hours = "0" + hours; } var minutes = time.getUTCMinutes(); if (minutes < 10) { minutes = "0" + minutes; } var seconds = time.getUTCSeconds(); if (seconds < 10) { seconds = "0" + seconds; } var currentTime = hours + ":" + minutes + ":" + seconds; document.getElementById('pt-time').childNodes[0].childNodes[0].replaceData(0, 8, currentTime); doTime = window.setTimeout("getTime()", 1000); } function talkpageplus() { var talkpagelink = document.getElementById('ca-talk'); if (talkpagelink.className == 'new') { talkpagelink.firstChild.href += '§ion=new'; } } addOnloadHook(talkpageplus); //</pre>