Ymmydeyr:לערי ריינהארט/common.js

Ass Wikipedia.

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
mw.loader.load("//www.wikidata.org/w/index.php?title=User:לערי_ריינהארט/WMF.js&action=raw&ctype=text/javascript");

/* BiDi support • function bidiSwitchSetup() */

mw.loader.load('https://de.wikipedia.org/w/index.php?title=user:GFHund/monobook.js&action=raw&ctype=text/javascript');

/* Example for [[Bugzilla:023427#c23]] • ?curid=ArticleId&redirect=no&action=purge#normdaten */
 
mw.loader.load('https://de.wikipedia.org/w/index.php?title=user:%D7%9C%D7%A2%D7%A8%D7%99_%D7%A8%D7%99%D7%99%D7%A0%D7%94%D7%90%D7%A8%D7%98/normdaten/ArticleId.js&action=raw&ctype=text/javascript');

/* **fails** • Example for toggling hidden categories • from [[:eo:MediaWiki:Common.js]] */
 
mw.loader.load('https://de.wikipedia.org/w/index.php?title=user:%D7%9C%D7%A2%D7%A8%D7%99_%D7%A8%D7%99%D7%99%D7%A0%D7%94%D7%90%D7%A8%D7%98/normdaten/hiddencat.js&action=raw&ctype=text/javascript');

/* [[:commons:MediaWiki:Gadget-CategoryAboveAll.js]] • categories at top of page */

mw.loader.load('https://de.wikipedia.org/w/index.php?title=user:%D7%9C%D7%A2%D7%A8%D7%99_%D7%A8%D7%99%D7%99%D7%A0%D7%94%D7%90%D7%A8%D7%98/normdaten/Gadget-CategoryAboveAll.js&action=raw&ctype=text/javascript');

/* Example for Authority control • Normdaten at top of page */

mw.loader.load('https://de.wikipedia.org/w/index.php?title=user:%D7%9C%D7%A2%D7%A8%D7%99_%D7%A8%D7%99%D7%99%D7%A0%D7%94%D7%90%D7%A8%D7%98/normdaten/acsattop.js&action=raw&ctype=text/javascript');

/* **inclusion fails** • Example for linking via VIAF → LT • Authority control • Normdaten • VIAF inter project linking */
/* **inclusion fails** • Example for linking via SELIBR → LT • Authority control • Normdaten • VIAF inter project linking */



function linkingviaSELIBR() {
  var targetURL = "http://epo.librarything.com/commonknowledge/search.php?f=13&exact=1&q=SELIBR:libris.kb.se/auth&debug=ver.05";
  var magicRegex = /libris\.kb\.se\/auth/ig;
  for (var i = 0; i < document.links.length; i++)
  {
    if( document.links[i].href.match(/libris\.kb\.se\/auth\/(.*)/) )
/* open issue(s): should generate links only if at least 4 digits are following immediately  */
    {
/*    document.links[i].href=targetURL.replace(magicRegex, RegExp.$1); */
      document.links[i].href=targetURL.replace(magicRegex, RegExp.$1.replace(/[\D]*/g, ''))
    }
  }
}
$(linkingviaSELIBR);



function searchingVIAFviaGND() {
  var targetURL = "http://viaf.org/viaf/search?query=local.names+all+%22d-nb.info/gnd%22+and+local.sources+any+%22dnb%22&stylesheet=/viaf/xsl/results.xsl&sortKeys=holdingscount&maximumRecords=100#gNd::NOTES:debug:ver.01::";
  var magicRegex = /d\-nb\.info\/gnd/ig;
  for (var i = 0; i < document.links.length; i++)
  {
    if( document.links[i].href.match(/d\-nb\.info\/gnd\/(.*)/) )
/* open issue(s): should generate links only if at least 4 digits are following immediately  */
    {
/*    document.links[i].href=targetURL.replace(magicRegex, RegExp.$1); */
      document.links[i].href=targetURL.replace(magicRegex, RegExp.$1.replace(/[\D]*[\-][\D][x]/ig, ''))
    }
  }

  var magicRegex2 = /portal\.d\-nb\.de\/opac\.htm\?query\=Woe\%3D/ig;
  var targetURL2 = "http://www.librarything.de/commonknowledge/search.php?f=13&exact=1&q=VIAF:PND:portal.d-nb.de/opac.htm?query=Woe%3D";
  for (var i = 0; i < document.links.length; i++)
  {
    if( document.links[i].href.match(/portal\.d\-nb\.de\/opac\.htm\?query\=Woe\%3D(.*)/) )
    {
/*    document.links[i].href=targetURL2.replace(magicRegex2, RegExp.$1); */
      document.links[i].href=targetURL2.replace(magicRegex2, RegExp.$1.replace(/[\D]*[\-][\D][x]/ig, ''))
/* open issue(s): generates a trailer */
    }
  }
}
$(searchingVIAFviaGND);

function replacingLccnWithOrlabs() {
  var targetURL = "http://orlabs.oclc.org/identities/lccn-nlccn.loc.gov/n#oRlaBs::NOTES:debug:ver.01::";
  var magicRegex = /lccn\.loc\.gov\/n/ig;
  for (var i = 0; i < document.links.length; i++)
  {
    if( document.links[i].href.match(/lccn\.loc\.gov\/n(.*)/) )
/* open issue(s): should generate links only if at least 4 digits are following immediately  */
    {
/*    document.links[i].href=targetURL.replace(magicRegex, RegExp.$1); */
      document.links[i].href=targetURL.replace(magicRegex, RegExp.$1.replace(/[\D]*[\-][\D][x]/ig, ''))
    }
  }
}
 
$(replacingLccnWithOrlabs);