User:Sander Säde/My scripts
From Wikipedia, the free encyclopedia
[edit] My scripts
I've created some scripts - none of them are all that good or useful as Twinkle or Popups. Most of them are related to WikiProject Estonia, but can be easily customized for other projects. Let me know on talk page here or my main talk page what do you think of them - or if you have any suggestions.
Please note that my scripts not described here are either work in progress or unsuitable for general use (too heavy load on servers, for example).
Note: These scripts are, as far as I know, harmless and will not overly stress Wikipedia servers. They work with Mozilla Firefox - I have not tested them with other browsers. In some cases, Twinkle may be needed, I will mention that in the script description if that is the case.
However, if my script crashes or freezes your browser, gives unwanted results or will make you wikiaddict... You have been warned and I cannot be held responsible for any of that.
Contents |
[edit] Installation
(instructions blatantly stolen from Twinkle)
- copy the script - or link to script - and paste it into the bottom of your monobook.js file:
- save the new monobook.js page, and
- completely refresh your browser by bypassing your cache (hit Control-Shift-R in Firefox or Control-F5 in Internet Explorer).
[edit] Script: Quick Preview
- Description: Adds button Quick preview to the edit form. Clicking it will do an AJAX call to update/show the preview. Much faster then regular preview, which requires reloading the whole page, also does not change the cursor position in the edit window, making it easier to continue editing. Unlike InstaView templates, images etc are rendered correctly, also the script is much "lighter" then InstaView.
- Installation: Add
importScript('User:Sander Säde/quickpreview.js');
to the bottom of your your monobook.js. - Script: User:Sander Säde/quickpreview.js
- Notes:
- Quick preview button will be disabled while getting the preview, also a notice on top of the page is shown then.
- I don't use access keys myself, but apparently quite a lot of people do. Access key for Quick Preview is g (most others were taken already). In Firefox you have to press Alt+Shift+G, in IE Alt+G and in Opera Shift-Esc-G. Pressing that combination counts as clicking on Quick preview button.
- I recommend fixing the height of the preview window and making it scrollable - otherwise it is highly annoying to scroll down to get to the edit form, if the page is long (that is recommended even if you don't use Quick Preview). That can be easily done by adding to your monobook.css line
#wikiPreview { max-height:350px; overflow:auto; }
. max-height:350px is the maximum height of the edit window, change it to fit your needs. If the preview height is longer then 350px, it becomes scrollable. Also, to save screen space, I hide the preview warning - add.previewnote { display: none; }
.
[edit] Script: Quick edit count
- Description: Adds quick edit count to top of Special:Contributions for all registered users:Edit count for Sander Säde: 4788
- Caveat: http://en.wikipedia.org/w/query.php doesn't seem to work with unregistered users, ie IP's.
- Inspired by: User:ais523/editcount.js - real count froze Firefox, quickcount used annoying popup.
- Installation: Copy/paste everything in the box below to your monobook.js.
addOnloadHook(doQuickCount); function doQuickCount() { if (wgPageName == "Special:Contributions") { var name = document.getElementById("contentSub").getElementsByTagName("a"); var rname = name[0].innerHTML; if (rname == "Talk") return; //IP var cnteraj = sajax_init_object(null); cnteraj.open("GET", 'http://en.wikipedia.org/w/query.php?what=contribcounter&'+ 'titles=User:'+rname+'&format=xml', true); cnteraj.onreadystatechange = function() { if(cnteraj.readyState != 4) return; document.getElementById("contentSub").innerHTML = 'Edit count for ' + rname.fontcolor("Green").bold() + ": " + cnteraj.responseText.split("<count>")[1].split("</count>")[0].fontcolor("Maroon").bold() + "<br/>" + document.getElementById("contentSub").innerHTML; }; cnteraj.send(null); } }
[edit] Script: View source
- Description: Adds tab source to all pages. Clicking on it will display wikisource of the page at the top of the page (note: page itself will not be affected in any way). In case of special, purely HTML pages, such as this, source will be the HTML source of the page.
- Caveat: Adding tab requires Twinkle. I will probably migrate required functions at some point, though.
- Installation: Add
importScript('User:Sander Säde/viewsource.js');
to the bottom of your your monobook.js. - Script: User:Sander Säde/viewsource.js
[edit] Script: Estonian articles to watchlist page
- Description: Add list of changes from WikiProject Estonia to the top of your watchlist, without need to add them actually to your watchlist.
- Installation: Copy/paste everything in the box below to your monobook.js.
- Instructions: If you need to change the options, edit the URL - namely
&hideminor=0&days=7&limit=50
, it should be self-explanatory.
addOnloadHook(estRelated); function estRelated() { if (document.URL.indexOf('Special:Watchlist') == -1) return; estaj=sajax_init_object(null); estaj.open("GET", "http://en.wikipedia.org/w/index.php?title=Special:Recentchangeslinked&target=User:Sander_S%C3%A4de/WPEarticles&hideminor=0&days=7&limit=50", true); estaj.onreadystatechange = function() { if(estaj.readyState != 4) return; sPage = estaj.responseText; document.getElementById("contentSub").innerHTML += "<br/>" + sPage.substring(sPage.indexOf("<h4>"), sPage.indexOf('<div class="printfooter">') - 25); }; estaj.send(null); }
[edit] Script: wpe:allest
- Description: Adds tab wpe:allest to the page. Clicking on it will give list of all WikiProject Estonia articles - in the end, also User:Sander Säde/WPEarticles will be updated. Note that your current page will not be affected in any way.
- Caveat: Adding tab requires Twinkle. I will probably migrate required functions at some point, though.
- Installation: Add
importScript('User:Sander Säde/allest.js');
to the bottom of your your monobook.js. - Script: User:Sander Säde/allest.js