Advertisement
Guest User

9gag NSFW

a guest
Sep 12th, 2014
355
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name        9gag NSFW SWEDISH VERSION
  3. // @namespace   9gag.com
  4. // @include     http://9gag.com/gag/*
  5. // @exclude     http://9gag.com/hot
  6. // @exclude     http://9gag.com/gif
  7. // @include     http://9gag.com/*
  8. // @version     2
  9. // @run-at      document-end
  10. // @grant       none
  11. // ==/UserScript==
  12.  
  13. function gagNsfw(gagDiv){
  14.     gagDiv.children().remove();
  15.     var href = gagDiv.parent().attr('href');
  16.     href = href.substr(href.lastIndexOf('/') + 1);
  17.     var img = $('<img class="badge-item-img" src="http://img-9gag-lol.9cache.com/photo/'+ href +'_460sa.jpg">');
  18.     img.load(function(){
  19.         $(this).attr('style',"height:"+$(this).height()+"px;"+"width:"+$(this).width()+"px;");
  20.         $(this).parent().attr('style',"min-height:"+$(this).height()+"px;"+"width:"+$(this).width()+"px;");
  21.     });
  22.     img.click(function() {return false;});
  23.     img.appendTo(gagDiv);
  24. }
  25.  
  26.     this.$=this.jQuery=jQuery.noConflict(true);
  27.     var allNsfw = $($('.nsfw-post'));
  28.     for (i = 0; i < allNsfw.length; i++) {
  29.         gagNsfw($(allNsfw[i]));        
  30.     }
  31.  
  32.  
  33. $(".badge-entry-collection").bind('DOMNodeInserted', function(e) {
  34.     var element = e.target;
  35.    
  36.     if(e.type == "DOMNodeInserted"){
  37.         gagNsfw($($(element).find(".nsfw-post")[0]));
  38.     }
  39. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement