User:Manishearth/Scripts/Snippets#Extra floating search bar

This page contains snippets which are not worthy to become scripts but are sometimes useful.

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.

FlexiDiff

function getID(){

if(document.getElementById('t-permalink')){

return document.getElementById('t-permalink').innerHTML.split("&oldid=")[1].split("\"")[0]

}else{return "No id"

}

}

addOnloadHook(

function(){

var diffPortlet='p-cactions'

/*can be:

p-navigation for navigation sidebar

p-tb for toolbox

p-interaction for interaction sidebar

  • /

if(window.location.href.indexOf("action=edit")==-1){

addPortletLink(diffPortlet,"javascript:prompt('The Id for this page is:',getID())",'ID', 'ca-id','Page ID', '')

addPortletLink(diffPortlet,"javascript:document.location='http://en.wikipedia.org/w/index.php?title=Main_Page&diff='+getID()+'&oldid='+prompt('Enter ID for other page',)",'FlexDiff', 'ca-diff','Get diffs for this page with any other page', )

}

}

)

Add it to 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.

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).