User:Onorem/monobook.js

//Interiot's javascript edit counter if (document.title.indexOf('User:Interiot/Tool2/code.js') != -1) { mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:Interiot/Tool2/code.js&action=raw&ctype=text/javascript'); }

importScript('User:AzaToth/twinkle.js'); TwinkleConfig = { revertMaxRevisions             :       50, userTalkPageMode               :       'window', showSharedIPNotice             :       false, openTalkPage                   :       [ 'agf', 'norm', 'vand' ], openTalkPageOnAutoRevert       :       false, openAOLAnonTalkPage            :       false, summaryAd                      :       " using TW", deletionSummaryAd              :       " using TW", protectionSummaryAd            :       " using TW", watchSpeedyPages               :       [ 'g3', 'g5', 'g10', 'g11', 'g12' ], watchProdPages                 :       true, openUserTalkPageOnSpeedyDelete :       [ 'g1', 'g2', 'g10', 'g11', 'g12', 'a1', 'a7', 'i3', 'i4', 'i5', 'i6', 'i7', 'u3', 't1' ], watchRevertedPages             :       [ ], markRevertedPagesAsMinor       :       [ ], deleteTalkPageOnDelete         :       false, watchWarnings                  :       false, markAIVReportAsMinor           :       true, markSpeedyPagesAsMinor         :       false, offerReasonOnNormalRevert      :       true };

function diff_only_buttons { handle_diff('differences-prevlink'); handle_diff('differences-nextlink'); function handle_diff(diff_id) {   var link = document.getElementById(diff_id); if (link == null) {     return false; }   var diff_only = document.createElement('a'); diff_only.id = diff_id; diff_only.href = link.href + '&diffonly=1'; diff_only.appendChild(document.createTextNode(' - (Diff only)')); link.parentNode.appendChild(diff_only); return true; } } addOnloadHook(diff_only_buttons)

/* Templates Used finder, version [0.0.3b] Originally from: http://en.wikipedia.org/wiki/User:Splarka/temused.js

Notes:
 * Uses the API using head/appendchild(script) and callback to avoid ajax.
 * Redesigned a-la http://en.wikipedia.org/wiki/User:Splarka/templatesabused.js (which is for edit mode)
 * This script is for view mode. Similar display, completely different method of operation.

if(wgNamespaceNumber != -1 && wgArticleId > 0 && wgAction == 'view') addOnloadHook(findTemButton) function findTemButton { var portlet = (window.temusedIAmATool) ? 'p-tb' : 'p-cactions'; mw.util.addPortletLink(portlet,'javascript:findTem','Templates used','ca-tem'); if(queryString('findtem')=='true') findTem; }

function findTem { var bar = document.getElementById('contentSub') || document.getElementById('topbar'); if(!bar) return; var div = document.createElement('div'); div.setAttribute('id','tem-out'); bar.appendChild(div); injectSpinner(div,'tem'); var url = mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/api.php?maxage=0&smaxage=0&format=json&callback=findTemCB&action=query&generator=templates&gtllimit=500&prop=revisions&indexpageids&titles=' + encodeURIComponent(mw.config.get('wgPageName')) ; mw.loader.load(url); }

function findTemCB(obj) { var tem = document.getElementById('tem-out'); removeSpinner('tem'); if(!obj['query'] || !obj['query']['pages']) { tem.appendChild(document.createTextNode('error, or no templates found')); return; } appendCSS('#ca-tem a {display:none;} #tem-out {border:1px solid #777777;} .tem-week {color:black;} .tem-day {font-weight:bold;} .tem-hour {color:red;}'); var ul = document.createElement('ul'); var ids = obj['query']['pageids']; for(var i=0;i 604800) li.className = 'tem-stale'; li.appendChild(document.createElement('br')); li.appendChild(document.createTextNode('Last edited: ')); var span = document.createElement('span'); span.appendChild(document.createTextNode(duration(timesince,2))); span.className = 'tem-time' if(timesince < 604800) span.className += ' tem-week' if(timesince < 86400) span.className += ' tem-day' if(timesince < 3600) span.className += ' tem-hour' li.appendChild(span) li.appendChild(document.createTextNode(' ago by ')); addLinkChild(li, wgScript + '?title=Special:Contributions/' + encodeURIComponent(rev['user']),rev['user']); li.appendChild(document.createTextNode(' ('));   addLinkChild(li, wgScript + '?diff=' + rev['revid'],'diff',false,false,'diff=' + rev['revid']);    li.appendChild(document.createTextNode(') ')); if(rev['comment']) li.appendChild(document.createTextNode(rev['comment'])) ul.appendChild(li); } tem.appendChild(ul); }

function addLinkChild(obj,href,text,id,classes,title) { if(!obj || !href || !text) return false; var a = document.createElement('a'); a.setAttribute('href',href); a.appendChild(document.createTextNode(text)); if(id) a.setAttribute('id',id); if(classes) a.setAttribute('class',classes); if(title) a.setAttribute('title',title); obj.appendChild(a); return a; }

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

//ISO 8601 date module by Paul Sowden, licensed under AFL. Date.prototype.setISO8601 = function(string) { if(!string) return var regexp = '([0-9]{4})(-([0-9]{2})(-([0-9]{2})(T([0-9]{2}):([0-9]{2})(:([0-9]{2})(\.([0-9]+))?)?(Z|(([-+])([0-9]{2}):([0-9]{2})))?)?)?)?'; var d = string.match(new RegExp(regexp)); if(d.length < 1) return var offset = 0; var date = new Date(d[1], 0, 1); if(d[3]) date.setMonth(d[3] - 1) if(d[5]) date.setDate(d[5]) if(d[7]) date.setHours(d[7]) if(d[8]) date.setMinutes(d[8]) if(d[10]) date.setSeconds(d[10]) if(d[12]) date.setMilliseconds(Number('0.' + d[12]) * 1000) if(d[14]) { offset = (Number(d[16]) * 60) + Number(d[17]); offset *= ((d[15] == '-') ? 1 : -1); } offset -= date.getTimezoneOffset; time = (Number(date) + (offset * 60 * 1000)); this.setTime(Number(time)); }

function duration(input,depth) { var num = input; var out = ''; var s = num % 60; num = Math.floor(num / 60); var m = num % 60; num = Math.floor(num / 60); var h = num % 24; num = Math.floor(num / 24); var d = num % 7; num = Math.floor(num / 7); var w = num % 52; num = Math.floor(num / 52); var y = num if(y > 0) out += y + 'yrs ' if(y + w > 0) out += w + 'wks ' if(y + w + d > 0) out += d + 'days ' if(y + w + d + h > 0) out += h + 'hrs ' if(y + w + d + h + m > 0) out += m + 'mins ' out += s + 'secs'; if(depth && depth < out.split(' ').length) { out = out.split(' ').slice(0,depth).join(' '); } return out; }