User:MateyY/global.js

/* All code on this page has been written by MateyY unless specified differently. Ask for permission before using. * This code affect all wikis MateyY goes to. */

//References for all elements var htmlDocument = document.getElementsByTagName("*"); var $html = $("*");

//Some scripts importArticles({   type: "script",    articles: [        //"w:community:User:MateyY/CommentsDisabled.js",        "w:dev:OasisToolbarButtons/code.js"    ] });

/* Extra rollback links * By Monchoman45 * Button and load talk altered */

function CustomRollbacks { var Buttons = [{ //Your buttons go here. You can copy and paste this to make more than three text: 'spam', title: 'Revert spam', summary: 'Spam.' }, {		text: 'vandalism', title: 'Revert vandalism.', summary: 'Vandalism.' }, {		text: 'unneeded', title: 'Revert unneeded.', summary: 'Unneeded.' }, {		text: 'consensus needed', title: 'Revert consensus needed', summary: 'Consensus needed.' }, {		text: 'per forum', title: 'Revert per forum consensus', summary: 'Per previous forum consensus.' }, {		text: 'clutter', title: 'Revert image clutter', summary: 'Clutter.' }, {		text: 'bad image', title: 'Revert bad image', summary: 'Bad image.' }, {		text: 'speculation', title: 'Revert speculation', summary: 'Speculation.' }, {		text: 'null', title: 'Revert with no summary', summary: ' ' //This one has no summary }];

var list = document.getElementsByTagName('span'); for(i in list) { if(list[i].className == 'mw-rollback-link') { var link = list[i]; var rollback = link.innerHTML; for(j in Buttons) { var customlink = document.createElement('span'); customlink.innerHTML = rollback; customlink.className = 'customrollback'; //we do this to avoid an infinite loop, because when we insert a into the DOM, the list variable includes it				customlink.getElementsByTagName('a')[0].title = Buttons[j].title; customlink.getElementsByTagName('a')[0].href += '&summary=' + Buttons[j].summary; customlink.getElementsByTagName('a')[0].innerHTML = Buttons[j].text; if(wgPageName == 'Special:RecentChanges' || wgPageName == 'Special:Contributions') { link.parentElement.appendChild(customlink); customlink.outerHTML = ' ' + customlink.outerHTML; }				else { //assumes you're on history link.parentElement.insertBefore(customlink, link.nextSibling); customlink.outerHTML = ' | ' + customlink.outerHTML; }			}		}	}	for(i in list) { //why another one of these? we're fixing the class that we set to avoid an infinite loop if(list[i].className == 'customrollback') { list[i].className = 'mw-rollback-link'; }	} } addOnloadHook(CustomRollbacks);

/* Replace "\-\-\-" with "—" on all text areas and text inputs * By MateyY */ $(function {    $("textarea").keydown(function { for (var i = 0; i < htmlDocument.length; i++) { document.getElementsByTagName("textarea")[i].value = document.getElementsByTagName("textarea")[i].value.replace(/\-\-\-/g,"—"); }    }); });

/* TESTING NEW VERSION OF CommentsDisabled.js! * Wikia comments update fixes */ /* The following script was created by MateyY. * Version: 2.1 * For skins: all * JavaScript library used: jQuery * Function: Informs user whether comments are removed and/or disabled by changing the text displayed in the button and the heading comment counter on the bottom of the page. * Build for use on: all wikis * Do NOT copy the code; import it! * Thank you! (function($) {    function commentsDisabled {          if ($(".WikiaArticleComments.loading").length === 0 && commentsInterval) {               if (commsDisabled) {                    clearInterval(commentsInterval);                    return;               }               if (skin === "oasis" || skin === "wikia") {                    if ($("#WikiaArticleComments").length <= 0) $.noop;                    else if (($("#article-comments").length <= 0) && ($("#WikiaPageHeader").length > 0) && ($("#WikiaPageHeader a.comments:contains('Comments')"))) {                         if ($("#WikiaPageHeader a.comments").length > 0) $("#WikiaPageHeader a.comments").html(' Comments disabled ');                         else if ($("#WikiaPageHeader ul.commentslikes li.comments span.commentsbubble").length > 0 && $('#WikiaPageHeader ul.commentslikes li.comments a[href="#WikiaArticleComments"]').length > 0) $("#WikiaPageHeader ul.commentslikes li.comments span.commentsbubble").html("disabled"); $(".controls").remove; $("#article-comments-counter-header").html("Comments are disabled"); } else if (($("#article-comments").length <= 0) && ($("#WikiaUserPagesHeader a.comments:contains('Comments')"))) { $(".WikiaBlogPostHeader a.comments").html(' Comments disabled '); $(".controls").remove; $("#article-comments-counter-header").html("Comments are disabled"); } else if ($("#article-comm").is(":disabled") || $(".no-comments-allowed").length > 0) { $(".WikiaBlogPostHeader a.comments").html(' Comments disabled '); $("#WikiaPageHeader a.comments").html(' Comments disabled '); $(".controls").remove; $("#article-comments-counter-header").append(' (disabled) '); }              } else { if ($("#article-comm").is(":disabled") || $(".no-comments-allowed").length > 0) { $("").insertBefore($("h1#firstHeading")); $("h1#firstHeading").appendTo($("header#pageHeader")); $("header#pageHeader").append(' Comments disabled '); $("#article-comments-counter-header").append(' (disabled) '); $(".controls").remove; } else if ($("#article-comments").length <= 0) { $("").insertBefore($("h1#firstHeading")); $("h1#firstHeading").appendTo($("header#pageHeader")); $("header#pageHeader").append(' Comments disabled '); $(".controls").remove; $("#article-comments-counter-header").html("Comments are disabled"); }              }               var commsDisabled = true; }    }     var commentsInterval = setInterval(commentsDisabled,500); })(jQuery);

/* See other JavaScript sheets I have written: ModuleStyle.js     Sample use: var gradient = true, startColor = "#000000", endColor = "#FFFFFF", borderRadiusPresent = true, borderRadiusLength = "10px"; importArticles({ type: "script", article:"User:MateyY/ModuleStyle.js" }); What you get is gradient and border radius on module boxes. Cross-browser support. All in two elementary lines of code.