User:Stefan2/global.js

From Meta, a Wikimedia project coordination wiki

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.
// <nowiki>

mw.loader.using(['mediawiki.util']).done( function () {

  // Fileinfo line from User:Magog the Ogre/monobook.js.
  if (mw.config.get('wgNamespaceNumber') == 6 && mw.config.get('wgSiteName') != 'Wikimedia Commons') {
    mw.util.addPortletLink("p-cactions", "https://tools.wmflabs.org/magog/oldver.php?project=" + mw.config.get('wgContentLanguage') + ".wikipedia"+"&src="+encodeURIComponent(mw.config.get('wgTitle')), "Old versions");
    mw.util.addPortletLink("p-cactions", "https://tools.wmflabs.org/magog/fileinfo.php?project=" + mw.config.get('wgContentLanguage') + ".wikipedia&information=1&authordate=1&license=1&fields=1&src="+encodeURIComponent(mw.config.get('wgTitle')), "File info");
    mw.util.addPortletLink("p-cactions", "https://commons.wikimedia.org/wiki/File:"+mw.config.get('wgTitle'), "Commons");
    mw.util.addPortletLink('p-cactions', 'http://tools.wikimedia.de/~magnus/commonshelper.php?language='+mw.config.get('wgContentLanguage')+'+&image='+encodeURIComponent(mw.config.get('wgTitle'))+'&commonsense=1&remove_categories=1&reallydirectupload=1', 'Commonshelper');
  }

  // Image reverse search. Based on Commons:MediaWiki:Gadget-GoogleImages.js and Commons:MediaWiki:Gadget-Tineye.js:
  if (mw.config.get('wgNamespaceNumber') == 6 && mw.config.get('wgSiteName') != 'Wikimedia Commons') {
    var images = document.getElementById('file').getElementsByTagName('img');
    var imageurl = images[0].parentNode.href;
    mw.util.addPortletLink('p-cactions', 'https://www.google.com/searchbyimage?image_url=' + encodeURIComponent(imageurl), 'Google Images');
    mw.util.addPortletLink('p-cactions', 'http://tineye.com/search?url=' + encodeURIComponent(imageurl) + '&sort=size&order=desc', 'TinEye');
    // This line doesn't seem to work: mw.util.addPortletLink('p-cactions', 'http://stu.baidu.com/i?objurl=' + encodeURIComponent(imageurl) + '&rt=0&rn=10&ftn=searchimage&ct=1&stt=0&tn=baiduimagepc', '百度图片');
  }

  // [[m:User:Hoo man/Scripts/Tagger]]
  mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:Hoo_man/tagger.js&action=raw&ctype=text/javascript');

  // Yellow bar for talk page messages on projects with [[mw:Extension:Echo]]:
  mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Writ_Keeper/Scripts/orangeBar.js&action=raw&ctype=text/javascript');

  // Disable Mediaviewer:
  mw.config.set("wgMediaViewerOnClick", false);

  // Disable Visual Editor:
  //mw.loader.load('//en.wikipedia.org/w/index.php?title=MediaWiki:Gadget-oldeditor.js&action=raw&ctype=text/javascript');

  if(typeof(taggerConfig) == 'undefined') taggerConfig = {};
  taggerConfig.tags = [];
  taggerConfig.editSummary = [];
  if (mw.config.get('wgContentLanguage') == "en" && mw.config.get('wgSiteName') == "Wikipedia") {
    taggerConfig.tags[1] = '{{db-g8}}';
    taggerConfig.editSummary[taggerConfig.tags[1]] = '{{db-g8}}';
    if (mw.config.get('wgNamespaceNumber') == 6) {
      taggerConfig.tags[2] = '{{subst:orfurrev}}';
      taggerConfig.editSummary[taggerConfig.tags[2]] = '{{subst:orfurrev}}';
      taggerConfig.tags[3] = '{{non-free reduce}}';
      taggerConfig.editSummary[taggerConfig.tags[3]] = '{{non-free reduce}}';
      taggerConfig.tags[4] = '{{di-missing article links|date={{subst:CURRENTTIMESTAMP}}}}';
      taggerConfig.editSummary[taggerConfig.tags[4]] = '{{di-missing article links|date={{subst:CURRENTTIMESTAMP}}}}';
      taggerConfig.tags[5] = '{{ShadowsCommons}}';
      taggerConfig.editSummary[taggerConfig.tags[5]] = '{{ShadowsCommons}}';
    }
  }
  else if (mw.config.get('wgSiteName') == 'Meta') {
    taggerConfig.tags[1] = '{{No license}}';
    taggerConfig.editSummary[taggerConfig.tags[1]] = 'File has no licence';
    taggerConfig.tags[2] = '{{No source}}';
    taggerConfig.editSummary[taggerConfig.tags[2]] = 'File has no source';
    taggerConfig.tags[3] = '{{No source}}{{No license}}';
    taggerConfig.editSummary[taggerConfig.tags[3]] = 'File is missing essential legal information';
  }
  else if (mw.config.get('wgSiteName') == 'Wikimedia Commons') {
    taggerConfig.tags[1] = '=== [[:{{subst:SUBJECTPAGENAME:{{subst:SUBPAGENAME}}}}]] ===\n';
    taggerConfig.editSummary[taggerConfig.tags[1]] = 'Adding header';
  }

});
// </nowiki>