Jump to content

User:Sander Säde/My scripts

From Wikipedia, the free encyclopedia

My scripts

[edit]

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.

Installation

[edit]

(instructions blatantly stolen from Twinkle)

  1. copy the script - or link to script - and paste it into the bottom of your common.js file:
  2. save the new common.js page, and
  3. completely refresh your browser by bypassing your cache (hit Control-Shift-R in Firefox or Control-F5 in Internet Explorer).

Script: Quick Preview

[edit]
  • 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" than 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; }.

Script: Quick edit count

[edit]
  • Description: Adds quick edit count to top of Special:Contributions for all registered users:Edit count: 11241
  • Caveat: Wikipedia API "list=users" function doesn't 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.
   importScript('User:Sander Säde/editcount.js');

Script: View source

[edit]
  • 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.
  • Installation: Add importScript('User:Sander Säde/viewsource.js'); to the bottom of your your monobook.js.
  • Script: User:Sander Säde/viewsource.js

Script: Estonian articles to watchlist page

[edit]
  • 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 common.js.
  • Instructions: If you need to change the options, edit the URL - namely &hideminor=0&days=7&limit=50&hidemyself=1 , it should be self-explanatory.
  • Style: WP:Estonia related changes are shown with smaller font and colored background. Change style='font-size:80%;background-color: HoneyDew' to suit your preferences.
$(document).ready(function() {
  if (document.URL.indexOf('Special:Watchlist') == -1) return;
  $.get("https://wiki.riteme.site/w/index.php?title=Special:Recentchangeslinked&target=Wikipedia:WikiProject Estonia/publicwatchlist&hideminor=0&days=7&limit=100",
	function(data) {
		var $changelist = $(".mw-changeslist");
		var $changes = $($.parseHTML(data));
    	$changelist.prepend($changes.find(".mw-changeslist").wrap("<p style='font-size:80%;background-color: HoneyDew'></p>").parent());
	}
);
});