User:OwenBlacker/vector.js
Jump to navigation
Jump to search
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.
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);