Advertisement
RenzXVI

Scripts from Dragon Rainbow

Aug 10th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         Scripts from Dragon Rainbow
  3. // @namespace    http://tampermonkey.net/
  4. // @version      0.1
  5. // @description  Various Scripts
  6. // @author       http://community.wikia.com/wiki/User:Dragon_Rainbow/global.js
  7. // @match        wikia.com
  8. // @grant        none
  9. // @include      wikia.com
  10. // @include      http://elderscrolls.wikia.com/
  11. // @include      http://terraria.wikia.com/
  12. // @include      http://kallenbearrp.wikia.com/
  13. // @include      http://metal.wikia.com/
  14. // @include      http://tl.elderscrolls.wikia.com/
  15. // @include      http://community.elderscrolls.wikia.com/
  16. // @exclude      ?action=edit
  17. // ==/UserScript==
  18.  
  19. (function() {
  20.     'use strict';
  21.  
  22.     // Your code here...
  23.    
  24. //******************************************************************************//
  25. //* * * * * * Codes below taken from User:Dragon_Rainbow/global.js * * * * * * *//
  26. //******************************************************************************//
  27.  
  28. //Highlight whitespace characters in diffs when they're the only thing in the change
  29. //Winner of most conspicuous missing feature for five consecutive years
  30. if (window.location.href.indexOf('diff=') !== -1) {
  31.     $('.diffchange-inline').each(function() {
  32.         if (!(new RegExp('\\S+').test($(this).text()))) {
  33.             $(this).css('background-color', 'red');
  34.         }
  35.     });
  36. }
  37.  
  38. //end
  39.  
  40.  
  41. /* Custom "NewFilesModule" by 452 (with fixes by JoshuaJSlone)
  42.    This script displays [[Special:NewFiles]] in the right rail
  43.    There are three ways to use this, by setting the NewFilesModuleCompact variable
  44.    0 - Normal, width is 212
  45.    1 - Compact, width is 106
  46.    2 - Random, if you're not sure which version you like best.
  47.  
  48.    In both modes, hovering over each displays the uploader info.
  49.  
  50.    NewFilesModuleCount can be used to specify the number of displayed images.
  51. */
  52. var NewFilesModuleCompact = 0; //must be 0, 1, or 2.
  53. var NewFilesModuleCount = 13; //any integer
  54.  
  55. if ($('#WikiaRail').length) { //only on pages where the rail is present
  56.   $('#WikiaRail').bind('DOMNodeInserted', function(event) { //fires after lazy-loading takes place.
  57.     if (!$("#NewFilesModule").length) { // Only add it ''once''
  58.       if (typeof $temp == "undefined") { // Only load it ''once''
  59.         $temp = $('<div>'); // this line, and the next, originate from http://dev.wikia.com/wiki/AjaxRC/code.js <3
  60.         $temp.load("/Special:NewFiles/" +NewFilesModuleCount + " #gallery-", function () {
  61.           $('#WikiaRail section:last-of-type').after("<section id='NewFilesModule' class='module'><h2><a href='/Special:NewFiles'>New Files</a><a class='wikia-button' href='/Special:Upload'>Upload</a></h2>");
  62.           if (typeof NewFilesModuleCompact == "undefined") NewFilesModuleCompact = 0;
  63.           if (NewFilesModuleCompact == 2) NewFilesModuleCompact = Math.floor(Math.random()*2);
  64.           if (NewFilesModuleCompact) {
  65.             $('#gallery-', $temp).html(
  66.               $('#gallery-', $temp).html()
  67.               .replace(/\/revision\/latest\?/g, "/revision/latest/scale-to-width-down/106?")
  68.               .replace(/\/scale-to-width-down\/\d*\?/g, "/scale-to-width-down/106?") //-down is redundant on this line, but kept for consistency
  69.             );
  70.             $("#NewFilesModule").addClass("compact");
  71.           }
  72.           $("#NewFilesModule").append('<div id="gallery-" hash="" class="wikia-gallery wikia-gallery-caption-below wikia-gallery-position- wikia-gallery-spacing- wikia-gallery-border- wikia-gallery-captions- wikia-gallery-caption-size-"></div>');
  73.           $(".wikia-gallery-item", $temp).each(function() {
  74.             $(".lightbox-caption", this).prepend($("<a>").attr("href",$(".gallery-image-wrapper>a", this).attr("href")).html($(".gallery-image-wrapper>a", this).attr("title")).append($("<br>")));
  75.             $("#NewFilesModule #gallery-").append(this);
  76.           });
  77.  
  78.           delete $temp; //delete it, in case the rail is wiped after this point.
  79.         });
  80.         if (!$("#NewFilesModuleCSS").length) $('head').append('<style type="text/css">\n#gallery- { position:relative;overflow-y:auto; clear: both; text-align:center; height:452px; }\n#gallery-:hover {padding-bottom: 13em; }\n#NewFilesModule .gallery-image-wrapper { top: 0 !important; height: auto !important; border:none; background: none; }\n#NewFilesModule.compact .gallery-image-wrapper { width: auto !important; }\n#NewFilesModule .thumb { height:auto !important; }\n#NewFilesModule .wikia-gallery-item { margin: 1px !important; padding: 0 !important; height: auto !important; border: none !important; }\n#NewFilesModule.compact .wikia-gallery-item { width: auto !important; }\n#NewFilesModule .wikia-gallery-item .lightbox-caption { display: none; }\n#NewFilesModule .wikia-gallery-item:hover .lightbox-caption { display:block; padding: 5px; margin-top: 0; position: absolute; border: 1px solid; background-color: #fff; z-index: 2; right: 0; width: 250px !important; }\n#NewFilesModule h2 {margin: 0 2em 0 0;}\n#NewFilesModule h2 a:first-child {color:inherit;}\n#NewFilesModule img { display: block; height: auto !important; width: auto !important; margin-left: auto !important; margin-top: auto !important;}\n.wikia-gallery-item .gallery-image-wrapper a { width: auto !important; height: auto !important; }\n.wikia-gallery-item .gallery-image-wrapper a.image-no-lightbox { line-height: normal; display: block; padding: 1em; }\n</style>');
  81.  
  82.       }
  83.     }
  84.   });  //end of DOMNodeInserted block
  85.   $('#WikiaRail').trigger('DOMNodeInserted'); //Prevent race condition by firing the event.
  86.  
  87. } /* End of custom "NewFilesModule " */
  88.  
  89.  
  90.    
  91. /* ---------------------------------Adds edit links to WLH page -- */
  92. function addEditLinksToWLH() {
  93.   if(wgCanonicalSpecialPageName=='Whatlinkshere')
  94.   {
  95.     var links = document.getElementById("mw-whatlinkshere-list").getElementsByTagName('li');
  96.     for(var i = 0; i<links.length; i++)
  97.     {
  98.       aLink = links[i].getElementsByTagName('a');
  99.       var linkHref = aLink[0].href.replace("\?redirect=no","")+"?action=edit";
  100.       var tools = getElementsByClassName(links[i], 'span', 'mw-whatlinkshere-tools');
  101.       var editLinkSpan = document.createElement("span");
  102.       editLinkSpan.className = "mw-whatlinkshere-edit";
  103.       editLinkSpan.innerHTML = '<a title="Edit form" href="' + linkHref + '">(edit)</a> ';
  104.       links[i].insertBefore(editLinkSpan,tools[0]);
  105.     }
  106.   }
  107. }
  108.  
  109. addOnloadHook(addEditLinksToWLH);
  110.    
  111. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement