User:Ned Scott/monobook.js

// ******************************************************START un-watch list if (mw.config.get('wgCanonicalSpecialPageName') && mw.config.get('wgCanonicalSpecialPageName')=='Watchlist' && mw.config.get('wgAction')=='view') $(function { var frm = document.getElementsByTagName('form')[0] frm.parentNode.insertBefore(document.createTextNode(' | '), frm) var lnk = document.createElement('a') lnk.appendChild(document.createTextNode('Unwatch…')) lnk.href = 'javascript:importScript("User:Alex_Smotrov/wlunwatch.js")' frm.parentNode.insertBefore(lnk, frm) }) // ******************************************************END un-watch list

// ******************************************************START Quick Preview importScript('User:Alex_Smotrov/qpreview.js'); // ******************************************************END Quick Preview

// ******************************************************Start History view if (mw.config.get('wgAction') == 'history') //add a link to call histComb.js $(function{ var pagehis = document.getElementById('pagehistory'); if (!pagehis) return; var lnk = document.createElement('a'); lnk.style.marginLeft = '10px'; lnk.href = '#'; lnk.appendChild(document.createTextNode('Improve…')); lnk.onclick=function{this.parentNode.removeChild(this);importScript('User:Alex_Smotrov/histcomb.js')} pagehis.parentNode.insertBefore(lnk, pagehis); }) // ******************************************************END History view

// ******************************************************START User:Splarka/watchimages.js /* Semi-automatic image watcher, version [0.0.3a] Originally from: http://en.wikipedia.org/wiki/User:Splarka/watchimages.js

Operation:
 * Checks which images are being used on a page
 * Sorts out those from commons, builds a list of those local or missing
 * Passes this list to Special:Watchlist/raw (but does not save, being a test script).
 * When saved, returns to the original page.

Notes:
 * The logic of which images to watch is easily changed (see below)
 * This avoids ajax editing (which is a pain). Possibly the API actions will be enabled later.

To do after more testing:
 * Abort if no matching images are found.
 * Check page more specifically for a content type (page has ID? etc).
 * Auto-submit if so desired.

if(mw.config.get('wgNamespaceNumber') != -1) addOnloadHook(watchAllImagesButton) function watchAllImagesButton { mw.util.addPortletLink('p-tb','javascript:watchAllImages','Watch images','t-wai','Add all images on this page to your watchlist.'); }

function watchAllImages { var wai = document.getElementById('t-wai'); if(wai) { wai.getElementsByTagName('a')[0].style.display = 'none'; var prog = document.createElement('img'); prog.setAttribute('id','wai-prog'); prog.setAttribute('src',stylepath + '/common/images/spinner.gif'); wai.appendChild(document.createTextNode('Working...')); wai.appendChild(prog); } var url = mw.config.get('wgServer') + mw.config.get('wgScriptPath') +'/api.php?action=query&format=json&callback=watchAllImagesCB&generator=images&prop=imageinfo&iiprop=&iilimit=1&titles=' + encodeURIComponent(mw.config.get('wgPageName')) var scriptElem = document.createElement('script'); scriptElem.setAttribute('src',url); scriptElem.setAttribute('type','text/javascript'); document.getElementsByTagName('head')[0].appendChild(scriptElem); }

function watchAllImagesCB(obj) { document.getElementById('wai-prog').style.display = 'none'; var towatch = ''; if(!obj['query'] || !obj['query']['pages']) return var images = obj['query']['pages']; for(var i in images) { // Logic variables to determine which images to watch // islocal = image is local, rather than shared (from commons). // haspage = has a description page, all local and some shared images have this. // hasmedia = the image exists, either locally or shared.

var islocal = (images[i]['imagerepository'] == 'local') var haspage = i > 0 var hasmedia = (images[i]['imagerepository'] != '')

//(!hasmedia || islocal) => all local images, as well as all missing (deleted or soon to be uploaded) images if(!hasmedia || islocal) { towatch += images[i]['title'] += '\n'; } }  var url = mw.config.get('wgServer') + mw.config.get('wgArticlePath').replace(/\$1/,'Special:Watchlist/raw') + '?fromtitle=' + encodeURIComponent(mw.config.get('wgPageName')) + '&towatch=' + encodeURIComponent(towatch); document.location.href = url; }

if(queryString('towatch') && mw.config.get('wgCanonicalSpecialPageName') == 'Watchlist') addOnloadHook(addToWatchlist) function addToWatchlist { var txt = document.getElementById('titles'); var towatch = decodeURIComponent(queryString('towatch')); if(!txt) return if(queryString('fromtitle')) { var forms = document.forms; for(var i=0;i<forms.length;i++) { if(forms[i].action.indexOf('Watchlist') != -1) { forms[i].action += '&pleasereturnto=' + queryString('fromtitle'); }   }  }  txt.value += towatch; alert('Note: the following images will be added to your watchlist upon save:\n' + towatch); }

if(queryString('pleasereturnto') && mw.config.get('wgCanonicalSpecialPageName') == 'Watchlist') addOnloadHook(addToWatchlistDone) function addToWatchlistDone { var url = mw.config.get('wgServer') + mw.config.get('wgArticlePath').replace(/\$1/,decodeURIComponent(queryString('pleasereturnto'))); document.location.href = url; }

function queryString(p) { var re = RegExp('[&?]' + p + '=([^&]*)'); var matches; if (matches = re.exec(document.location)) { try { return decodeURI(matches[1]); } catch (e) { } }  return null; } // ******************************************************END User:Splarka/watchimages.js

// ******************************************************START delsort via TWINKLE importScript('User:Quarl/util.js'); importScript('User:Quarl/wikipage.js'); importScript('Wikipedia:WikiProject User scripts/Scripts/Add LI menu'); importStylesheet('Wikipedia:WikiProject User scripts/Scripts/Add LI menu/css'); importScript('User:AzaToth/morebits.js'); importScript('Wikipedia:WikiProject Deletion sorting/delsort.js'); DelsortConfig = { debugLevel : 0, watchDelsortedLists : 0, watchDelsortedAfd : 0, } // ******************************************************END delsort via TWINKLE

// ******************************************************START warn and report via TWINKLE // Note, this requires User:AzaToth/morebits.js, which is imported in the delsort section importScript('User:AzaToth/twinklewarn.js'); importScript('User:AzaToth/twinklearv.js'); // ******************************************************END warn and report via TWINKLE

// ******************************************************START FRIENDLY tag // Note, this requires User:AzaToth/morebits.js, which is imported in the delsort section importScript('User:Ioeth/friendlytag.js'); // ******************************************************END FRIENDLY tag