Jump to content

User:Storkk/monobook.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
//Interiot's javascript edit counter
if (document.title.indexOf('User:Interiot/Tool2/code.js') != -1) {
  mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:Interiot/Tool2/code.js&action=raw&ctype=text/javascript'); }

// <!--   Divider --> 

//Edit Top Section
// This will add an [edit] link at the top of all pages except preview pages and the main page
// by User:Pile0nades
// Add an [edit] link to pages
$(function () {
// if this is preview page or generated page, stop
  if(document.getElementById("wikiPreview") || window.location.href.indexOf("/wiki/Special:") != -1) return;
  // if this is a revision history, stop
  if(document.getElementById("histlegend‎") || window.location.href.indexOf("/wiki/Special:") != -1) return;
  // if this is a diff page, stop
  if(document.getElementById("difference‎") || window.location.href.indexOf("/wiki/Special:") != -1) return;
  // if this is a watchlist, stop
  if(document.getElementById("watchdetails") || window.location.href.indexOf("/wiki/Special:") != -1) return;
  // if this is the main page, stop
  if(document.getElementById("mainpage") || window.location.href.indexOf("/wiki/Special:") != -1) return;
  // get the page title
  var pageTitle = document.title.split(" - ")[0].replace(" ", "_");
  // create div and set innerHTML to link
  var divContainer = document.createElement("div");
  divContainer.innerHTML = '<div class="editsection" style="float:right;margin-left:5px;margin-right:0px;margin-top:47px;">[<a href="/w/index.php?title='+pageTitle+'&action=edit&section=0" title="'+document.title.split(" - ")[0]+'">edit</a>]</div>';
  // insert divContainer into the DOM below the h1
  if(window.location.href.indexOf("&action=edit") == -1)
    document.getElementById("content").insertBefore(divContainer, document.getElementsByTagName("h1")[0]);
  if(window.location.href.indexOf("&action=edit&section=0") != -1)
    document.getElementById("wpSummary").value = "/* Intro */ ";
});

// <!--  Divider  -->

// addPurge to tabs
$( function (){
    var x = document.getElementById('ca-history');
    if(!x) return;
    if(x.children) x = x.children[0].href;
    else x = x.childNodes[0].href;
    addLink("p-cactions", x.replace(/=history/, "=purge"), 'purge', 'ca-purge', 'Purge the internal cache for this page', 0);
});

// <!--  Divider -->


//addtabs
function addTab(url, name, id, title, key){
    var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
    return addlilink(tabs, url, name, id, title, key)
};

//addlinks
function addLink(where, url, name, id, title, key, after){
    //* where is the id of the toolbar where the button should be added;
    //   i.e. one of "p-cactions", "p-personal", "p-navigation", or "p-tb".
    //
    //* url is the URL which will be called when the button is clicked.
    //   javascript: urls can be used to do more complex things.
    //
    //* name is what will appear as the name of the button.
    //
    //* id is the id of the button; it's best to define one.  
    //   Use a prefix to make sure its unique. Optional.
    //
    //* title is the tooltip title that gives a longer description 
    //   of the button; if you define a accesskey, mention it here. Optional.
    //
    //* key is the char you want for the accesskey. Optional.
    //
    //* after is the id of the button you want to follow this one. Optional.
    //
    var na = document.createElement('a');
    na.href = url;
    na.appendChild(document.createTextNode(name));
    var li = document.createElement('li');
    if(id) li.id = id;
    li.appendChild(na);
    var tabs = document.getElementById(where).getElementsByTagName('ul')[0];
    if(after) {
        tabs.insertBefore(li,document.getElementById(after));
    } else {
        tabs.appendChild(li);
    }
    if(id && typeof ta !== 'undefined') {
        if(key && title) { ta[id] = [key, title]; }
        else if(key) { ta[id] = [key, '']; }
        else if(title) { ta[id] = ['', title];} 
    }
    // re-render the title and accesskeys from existing code in wikibits.js
    if (typeof akeytt !== 'undefined') akeytt();
    return li;
}
//add li link
function addlilink(tabs, url, name, id, title, key){
    var na = document.createElement('a');
    na.href = url;
    na.appendChild(document.createTextNode(name));
    var li = document.createElement('li');
    if(id) li.id = id;
    li.appendChild(na);
    tabs.appendChild(li);
    if(id)
    {
        if(key && title)
        {
            ta[id] = [key, title];
        }
        else if(key)
        {
            ta[id] = [key, ''];
        }
        else if(title)
        {
            ta[id] = ['', title];
        }
    }
    // re-render the title and accesskeys from existing code in wikibits.js
    akeytt();
    return li;
}

// <!--ais523 edit counter-->
// Script from [[User:ais523/editcount.js]]
document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:ais523/editcount.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');

//addOnloadHook(function(){ecAddTab("javascript:alert('This is a test');","ca-test","test","");});

//starting nfurbacklink.js:
importScript("User:Storkk/nfurbacklink.js");