Guest User

Untitled

a guest
Mar 1st, 2016
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name        Block youtube users
  3. // @namespace   #perunaonparas
  4. // @include     *youtube.com/*
  5. // @exclude     *my_videos*
  6. // @grant       GM_getValue
  7. // @grant       GM_setValue
  8. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
  9. // @require https://gist.github.com/raw/2625891/waitForKeyElements.js
  10. // @version     2.992
  11. // ==/UserScript==
  12.  
  13.  
  14.  
  15. var blocks = GM_getValue('savedblocks', '');
  16. var blockvideo = GM_getValue('blockvideo', true);
  17. var censors = blocks.split(",");
  18.  
  19. for (var i = 0; i < censors.length; i++) {
  20.     censors[i] = censors[i].trim().toLowerCase();
  21. }
  22.  
  23. function initcensors()
  24. {
  25.    
  26.     blocks = GM_getValue('savedblocks', '');
  27.     blockvideo = GM_getValue('blockvideo', true);
  28.      censors = blocks.split(",");
  29.    
  30.     for (var i = 0; i < censors.length; i++) {
  31.         censors[i] = censors[i].trim().toLowerCase();
  32.     }
  33. }
  34.  
  35.  
  36.  
  37.  
  38. function opensettings()
  39. {
  40.     initcensors();
  41.     var settingsDiv = '<div style="padding:10px;margin-top:100px;margin-left:500px" id="blocksettingsdiv"><p>Blocks:</p> <textarea id="blockslist" cols="90" rows="10">'+blocks+'</textarea><br>Don'+"'"+'t show the video on watchpage (if you are watching a video from this user): <input type="checkbox" id="checkb"><br> <input type="submit" id="saveblocks" value="SAVE"><div id="saved"></div></div>';
  42.    //$(settingsDiv).insertBefore('#masthead-expanded-acct-sw-container');
  43.     $('body').prepend(settingsDiv);
  44.     document.getElementById("checkb").checked=blockvideo;
  45.     $("#saveblocks").click(savesettings);
  46.    
  47.     $("#myButton").unbind("click");
  48.     $("#myButton").click(closesettings);
  49.    
  50. }
  51.  
  52. function closesettings()
  53. {
  54.    document.getElementById("blocksettingsdiv").remove();
  55.     $("#myButton").unbind("click");
  56.     $("#myButton").click (opensettings);
  57. }
  58.  
  59. function savesettings()
  60. {
  61.     GM_setValue("savedblocks", $('#blockslist').val());
  62.     GM_setValue("blockvideo", document.getElementById("checkb").checked);
  63.     $("#saved").append("<strong>SAVED!</strong>");
  64.     closesettings();
  65.    
  66. }
  67.  
  68. function filter(jNode)
  69. {
  70.     try{
  71.         var temp = jNode[0];
  72.         var badword = temp.innerHTML;
  73.         if(        (censors.indexOf(badword.trim().toLowerCase()) != -1) || (badword.trim().toLowerCase().indexOf("vevo") != -1)  || (badword.trim().toLowerCase().indexOf("#musique") != -1)          )
  74.         {
  75.             temp = temp.parentNode;
  76.             for (var a=0; a<15; a++) {
  77.                 if(temp == null) {break;}
  78.                 temp = temp.parentNode;
  79.                
  80.                 if(temp.tagName == "LI") {
  81.                     if(temp.parentNode != null) {
  82.                     temp.parentNode.removeChild(temp);
  83.                     }
  84.                     break; 
  85.                 }
  86.                
  87.                
  88.                 if(temp.id == "watch7-main") {
  89.                     if(blockvideo == true){
  90.                          var temptemp = temp.parentNode;
  91.                         if(temptemp != null) {
  92.                          temptemp.removeChild(temp);
  93.                         }
  94.                         $( "#player" ).remove();
  95.                         temptemp.innerHTML="<div align='center'><p style='font-size:16px'>Video uploaded by "+badword+" and therefore blocked.</p><p style='font-size:9px'>You can watch this video by changing the setting from <i>Edit Blocks</i>.</div>";
  96.                     }
  97.                     break;
  98.                 }
  99.                
  100.                
  101.             }
  102.         }
  103.     } catch(e) {}
  104. }
  105.  
  106.  
  107.  
  108.  
  109. var t = document.querySelector("#guide-container .guide-user-links");
  110. if( t != null){
  111.     var d = document.createElement("li");
  112.     d.className="guide-channel";
  113.     d.innerHTML = '<a class="guide-item yt-uix-sessionlink yt-valign" id="myButton" href="#" title="Vidéos Bloquées"> <span class="yt-valign-container"> <span class="display-name"> <span>Vidéos Bloquées</span> </span> </span> </a>';
  114.     t.appendChild(d);
  115.     $("#myButton").click (opensettings);
  116. }
  117.  
  118. if(window.location.href == "http://www.youtube.com/#editblocks") { opensettings(); }
  119. waitForKeyElements('.g-hovercard', filter);
  120. waitForKeyElements('.yt-user-name', filter);
  121. waitForKeyElements('.qualified-channel-title', filter);
  122. waitForKeyElements('.qualified-channel-title-text', filter);
  123. waitForKeyElements('.shelf-title', filter);
  124. waitForKeyElements('.yt-uix-sessionlink', filter);
Add Comment
Please, Sign In to add comment