User:OwenBlacker/vector.js: Difference between revisions

From Wikimedia UK
Jump to navigation Jump to search
(Imported from en-wiki, with imported scripts commented out)
 
(Blanked)
 
Line 1: Line 1:
function moreLinks()
{
  if (navigator.userAgent.indexOf("Opera Mini") > 0) return;


  var tabs = document.getElementById('p-cactions').cloneNode(true);
  // don't use the same ids twice- replace the p-cactions id and prepend 'mytabs-' to the li's
  tabs.id = 'mytabs';
  // needs this to be set from js, it ignores the css width for some reason
  tabs.style.width = '100%';
  var listitems = tabs.getElementsByTagName('LI');
  for (i = 0; i < listitems.length; i++) {
    if (listitems[i].id) listitems[i].id = 'mytabs-' + listitems[i].id;
    if (listitems[i].accesskey) listitems[i].accesskey = "";
  }
  // drop them at the bottom of the content area
  document.getElementById('column-content').appendChild(tabs);
}
function AddCommonsTab()
{
  if (document.getElementsByClassName("sharedUploadNotice") != null)
  {
      addPortletLink("p-cactions", "http://commons.wikimedia.org/wiki/" + wgPageName, "Commons", '', "this image on the Commons");
  }
}
function AddPurgeTab()
{
  if (wgCanonicalNamespace != "Special")
  {
      addPortletLink("p-cactions", "/w/index.php?title=" + wgPageName + "&action=purge", "Purge", '', "purge the cache");
  }
}
function externISBN() {
  for (var i = 0; i < document.links.length; i++)
  {
      if (wgPageName != "Special:BookSources"
        && !(wgTitle == "Book sources" && wgCanonicalNamespace == "Project"))
      {
        if (document.links[i].href.match(/Special:BookSources\/(.{10,13})$/i))
        {
          document.links[i].href = "http://www.amazon.co.uk/o/ASIN/" + RegExp.$1 + "/bookaid";
        }
      }
  }
}
function fixBadSearches()
{
  if (navigator.userAgent.indexOf("MSIE") > 0) return;
  var elems = document.getElementsByClassName("noarticletext");
  var url = String(document.location) + '';
  if (
      elems != null && elems.length > 0
      && (url.indexOf('+') > 0 || url.indexOf('%2B') > 0)
      && url.indexOf("autoredirect=true") < 0
      && url.indexOf("monobook.js") < 0
  )
  {
      document.location.replace(url.replace(/\+|(%2B)/gi, '_') + "?autoredirect=true");
  }
}
addOnloadHook(externISBN);
//addOnloadHook(moreLinks);
addOnloadHook(fixBadSearches);
addOnloadHook(AddCommonsTab);
addOnloadHook(AddPurgeTab);

Latest revision as of 12:32, 6 June 2018