Χρήστης:GeorgeMoney~elwiki/monobook.js

Από τη Βικιπαίδεια, την ελεύθερη εγκυκλοπαίδεια

Μετά την αποθήκευση πρέπει να καθαρίσετε την κρυφή μνήμη (cache) του browser σας για να δείτε τις αλλαγές: Σε Chrome, Firefox, Safari, Internet Explorer και Edge: Κρατήστε πατημένο το Shift και κάντε κλικ στο κουμπί Ανανέωση στην μπάρα εργαλείων.

//<pre><nowiki>

// ------- HELPER FUNCTIONS ---------
function addToolboxLink(url, name, id){
    var tb = document.getElementById('p-tb').getElementsByTagName('ul')[0];
    addlilink(tb, url, name, id);
}
// 
function addTopLink(url, name, id){
    var personal = document.getElementById('p-personal').getElementsByTagName('ul')[0];
    addlilink(personal, url, name, id);
}
// 
function addNavLink(url, name, id){
    var navigation = document.getElementById('p-navigation').getElementsByTagName('ul')[0];
    addlilink(navigation, url, name, id);
}
// 
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) {
        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;
}
    
// 

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;
}

// 

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

// ---------- END HELPER FUNCTIONS ---------


// -------------Add an [edit top] 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;

  // 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:15px;margin-top:3px;">[<a href="/w/index.php?title='+pageTitle+'&action=edit&section=0" title="'+document.title.split(" - ")[0]+'">edit top</a>]</div>';

  // insert divContainer into the DOM before 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 */ ";
});

// ------------FORCE SUMMARY

function addForceSummary()
{
    if(!/&action=edit/.test(window.location.href) && !/&action=submit/.test(window.location.href)) return;
    if(/&section=new/.test(window.location.href)) return;
    if(!document.forms.editform) return;
    document.forms.editform.wpSave.onclick = forceSummary;
}

function forceSummary()
{
    if(!document.forms.editform.wpSummary.value.replace(/^(?:\/\\*.*\\*\/)? *(.*) *$/,'$1'))
    {
        var r = prompt('Are you sure you want to submit without adding a summary?\nTo add a summary, type it in the box below:',document.forms.editform.wpSummary.value);
        if(r == null) { return false; }
        document.forms.editform.wpSummary.value = r;
    }
    return true;
}

$(addForceSummary);



// --------------------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'); }


//-----------------Admin-like RC Patrol tools

document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:VoA/monobook.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');

//</nowiki>[[Category:RC scripted users]]<nowiki>

// -------------------------Replace txt
document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Voice_of_All/replacetxt.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
//

// --------------------Log tools
document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Voice_of_All/Sleeper/monobook.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');

// -------------------------Greeting
function addGreetLinks() {
  var guff='&autoclick=wpSave&autosummary=Welcome%20to%20Wikipedia!&preload=User%3AGeorgeMoney%2FWelcome&editintro=Template%3AThisisnotatemplate&section=new&create=Welcome';
  var lis=document.getElementById('content').getElementsByTagName('li');
  for (var i=0; i<lis.length; ++i) {
    var as=lis[i].getElementsByTagName('a');
    var greet=as[1].cloneNode(true);
    greet.removeChild(greet.childNodes[0]);
    greet.appendChild(document.createTextNode('greet'));
    greet.href += '&action=edit' + guff;
    greet.removeAttribute('class');
    as[1].parentNode.appendChild(document.createTextNode(' '));
    as[1].parentNode.appendChild(greet);
  }
}
$(function(){if (/title=Special(%3A|:)Log&type=newusers/.test(document.location.href)){addGreetLinks();};});

//------------ADD EDIT COUNT LINK
$(function () {
        if (document.getElementById('t-contributions')) {
                z=document.getElementById("content").childNodes;
                for (var n=0;n<z.length;n++) { 
                        if (z[n].className=="firstHeading") var username = z[n].textContent.replace(new RegExp('User(?:[ _]talk)?:([^/]*)', 'g'), '$1');
                };
                var toolbox = document.getElementById('p-tb').getElementsByTagName('ul')[0];
                var link = document.createElement('a');
                link.href = '/wiki/User:Interiot/Tool2/code.js?username='+username;
                link.appendChild(document.createTextNode('Edit count'));
                var li = document.createElement('li');
                li.appendChild(link);
                toolbox.appendChild(li);
        }
});

//-------------------My editcount
$(function(){addTopLink('http://en.wikipedia.org/wiki/User:Interiot/Tool2/code.js?username=GeorgeMoney', 'edit count');});

// ------------ADD VARIOUS LINKS TO NAV
$(function(){addNavLink('http://en.wikipedia.org/w/index.php?title=Special%3ALog&type=newusers&user=&page=', 'New user log');});
$(function(){addNavLink('http://en.wikipedia.org/wiki/User:GeorgeMoney/monobook.css', 'monobook.css');});
$(function(){addNavLink('http://en.wikipedia.org/wiki/User:GeorgeMoney/monobook.js', 'monobook.js');});
$(function(){addNavLink('http://wiki.xyrael.net/mediawiki/index.php?title=Special:Recentchanges', 'Test Wiki');});


//</pre></nowiki>