User:Yair rand/orangelinks.js

From Wiktionary, the free dictionary
Jump to navigation Jump to search

Note – after saving, you may have to bypass your browser’s cache to see the changes.

  • Mozilla / Firefox / Safari: hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (Command-R on a Macintosh);
  • Konqueror and Chrome: click Reload or press F5;
  • Opera: clear the cache in Tools → Preferences;
  • Internet Explorer: hold Ctrl while clicking Refresh, or press Ctrl-F5.

// The idea for this script was taken from [[User:Hippietrail/ajaxtranslinks.js]].
wgNamespaceNumber || addOnloadHook(function(){
  var r = [], v = [], f = $("#bodyContent a[href*=\"#\"]:not(.new,[href^=\"#\"],[href*=\":\"],#languageLinks a)")
  f.each(function(){
    var b = decodeURI(this.href.split("/wiki/")[1]).replace(/\./g, '%').replace(/_/g,' ').split("#"); 
    v.push(b);
    $.inArray(b[0],r) == -1 && r.push(b[0])
    })
  r.length && JsMwApi()({action:'query',prop:'revisions',rvprop:'content',titles:r.splice(0,$.inArray("sysop",wgUserGroups) == -1?50:500).join("|")},function(p){
    var j = p.query.pages;
    f.each(function(g){
      for(var i in j){
        if(j[i].title == v[g][0] && j[i].revisions[0]['*'].indexOf("=="+v[g][1]+"==") == -1){
          this.className = 'partlynew'
          }
        }
      })
    })
  })