Content deleted Content added
Manishearth (talk | contribs) |
m Replaced deprecated <source> tags with <syntaxhighlight> |
||
(10 intermediate revisions by 2 users not shown) | |||
Line 1:
This page contains snippets which are not worthy to become scripts but are sometimes useful.<br />
Usually these are scripts which I made in response to a request at [[WP:VPT]] or [[WP:US/R]]. They don't take much time to make but are sometimes useful.
If you think that a snippet should be promoted to a script (with its own page, documentation, etc), please post an RfS (Request for ScriptShip :P) on my talk page.
==Extra floating search bar==
Adds an extra search bar to the page, and a portlet of links, which
Links and Searchbox are minimizable. The third button next to the searchbox opens the page in a new tab.
<
//
function
var el = document.getElementById(obj);
if ( el.style.display != 'none' ) {
Line 16 ⟶ 19:
//Floating faithful search bar
addOnloadHook(function(){
document.getElementById("
document.getElementById("searchInput2").onkeyup=function (){document.getElementById("searchInput2Suggest").style.position="fixed"}
//And some nice little links
document.getElementById('floatcont').innerHTML+='<div id="p-personal2"><span><a onclick="
addPortletLink("p-personal2",mw.config.get('wgServer')+"/wiki/Special:OldReviewedPages","Pending Changes");
addPortletLink("p-personal2",mw.config.get('wgServer')+"/wiki/Special:Watchlist","Watchlist");
addPortletLink("p-personal2",mw.config.get('wgServer')+"/wiki/User:"+mw.config.get('wgUserName'),mw.config.get('wgUserName'));
addPortletLink("p-personal2",mw.config.get('wgServer')+"/wiki/User_talk:"+mw.config.get('wgUserName'),"Talk");
addPortletLink("p-personal2",mw.config.get('wgServer')+"/wiki/Special:Preferences","Preferences");
addPortletLink("p-personal2",mw.config.get('wgServer')+"/wiki/Special:Contributions/"+mw.config.get('wgUserName'),"My contribs");
});
</syntaxhighlight>
One bug (minor) If you have already scrolled down, the first letter typed into the box will cause the suggestion menu to pop up elsewhere, but this is fixed by typing another letter.
Here is an add-on, to be put directly under above script. It allows you to add little notifications with an addNotification() method. Its argiments are:
*link-- What to link to (whole url, please)
*image-- The url of the image to display. If this param is 'info', 'exclamation', or 'stophand', it will show the standard wikipedia notification images (The ones from the vandalism templates.)
*title-- The alt-text to show
The script adds a notification when you have new messages.
<syntaxhighlight lang=javascript>
function addNotification(link, image,title){
var src;
switch(image){
case 'exclamation':
src='http://upload.wikimedia.org/wikipedia/commons/thumb/f/f7/Nuvola_apps_important.svg/25px-Nuvola_apps_important.svg.png';
break;
case 'stophand':
src='http://upload.wikimedia.org/wikipedia/en/thumb/f/f1/Stop_hand_nuvola.svg/30px-Stop_hand_nuvola.svg.png';
break;
case 'info':
src='http://upload.wikimedia.org/wikipedia/commons/thumb/2/28/Information.svg/25px-Information.svg.png';
break;
default:
src=image;
}
document.getElementById('notifications').innerHTML+='<a href="'+link+'"><img src="'+src+'" title="'+title+'"/></a>'
}
if(document.getElementById('mw-youhavenewmessages')){
addNotification("http://en.wikipedia.org/wiki/User_talk:"+mw.config.get('wgUserName'),"exclamation","You have new messages");
}
</syntaxhighlight>
==FlexiDiff==
<
function getID(){
if(document.getElementById('t-permalink')){
Line 55 ⟶ 88:
}
)
</syntaxhighlight>
Add it to [[Special:Mypage/monobook.js|your monobook js page]] (go to vector.js if you use beta) and purge your cache. You'll get two new tabs (or links in your chosen portlet if you change the diffPortlet variable). In beta, the tabs will be hidden under a little down arrow next to the history tab and 'watch this page' star.<br />
To get a diff, first open the page you want on the left of the diff, and click ID. Copy the ID, and open the page you want on the right. Click the FlexDiff button (It should be right next to/under the ID tab), and it will ask for the ID that you copied. Paste it and click OK. The diff will open in the same window (no need for a new window as the script doesn't work on edit pages).
|