Third Party Content Remover

Great for removing ads. (I still recomend using Adblock Plus) (There are tools under User Script Commands)

  1. // ==UserScript==
  2. // @name Third Party Content Remover
  3. // @description Great for removing ads. (I still recomend using Adblock Plus) (There are tools under User Script Commands)
  4. // @include *
  5. // @exclude file:///*
  6. // @exclude data:*/*;base64,*
  7. // @version 0.0.1.20140525024113
  8. // @namespace https://gf.qytechs.cn/users/2178
  9. // ==/UserScript==
  10. // If you are looking at the code to manually edit the white list go to about:config and "paste greasemonkey.scriptvals./Third Party Content Remover.WL" without quotes.
  11. var whiteList;
  12. if (GM_getValue("WL")){
  13. whiteList = GM_getValue("WL");
  14. }
  15. else{
  16. whiteList = '';
  17. }
  18. function Removed(e){
  19. if (!removed) {
  20. removed='Nothing has been removed.';
  21. }
  22. alert('Removed Objects:\n'+removed.slice(0,removed.length-1));
  23. }
  24. function add2List(e){
  25. var WL = prompt("Please enter sites to allow as a 3ed party.\nSeparate them with commas (,).\nUse base 2nd level Domains\nex: photobucket.com,tinypic.com,tinyurl.com,gmodules.com\nType 'ClearWhiteList' (without quotes) to reset the White List","")
  26. if (WL == 'ClearWhiteList'){
  27. GM_deleteValue("WL");
  28. }
  29. else if (WL==''){
  30. //Apparently you just want to view the list.
  31. }
  32. else if (WL.indexOf('.')==-1){
  33. alert('I thought I told you to use base 2nd level Domains.');
  34. }
  35. else if (!GM_getValue("WL")) {
  36. GM_setValue("WL", WL);
  37. }
  38. else if (GM_getValue("WL")){
  39. GM_setValue("WL", GM_getValue("WL")+','+WL);
  40. }
  41. if(GM_getValue("WL")){
  42. alert("Your White List contains:\n"+GM_getValue("WL").replace(/,/g,'\n'));
  43. }
  44. else{
  45. alert("Your White List is empty.");
  46. }
  47. }
  48. var loc, This, i, x, l, temp, note, removed;
  49. loc = document.domain;
  50. for (i=0;i<=i+1;i++){
  51. //This changes stuff like 's2c.d.example.com' or 'sage.example.com' to 'example.com' for evaluation.
  52. if(loc.indexOf('.')!=loc.lastIndexOf('.')){
  53. //Anything in here is getting sliced and diced, lol
  54. loc=document.domain.slice(document.domain.indexOf('.')+1);
  55. }
  56. else{
  57. //There is no more stuff to remove from search term.
  58. break;
  59. }
  60. }
  61. note = "This has been removed by the 'Third Party Content Remover' GreaseMonkey script";
  62. //The note will show up to remind you the page was edited when viewing the source code with firebug. (https://addons.mozilla.org/en-US/firefox/addon/1843)
  63. removed='';
  64. for (i=0;i < document.getElementsByTagName('link').length;i++) {
  65. This = document.getElementsByTagName('link')[i];
  66. if (This.href) {
  67. //Anything in here has a href attribute.
  68. if (This.href.slice(0,4) !='data:') {
  69. //Anything in here is not a data uri.
  70. temp = document.createElement('a');
  71. temp.setAttribute('href',This.href);
  72. source = temp.hostname;
  73. for (x=0;x<=x+1;x++) {
  74. //This changes stuff like 's2c.d.example.com' or 'sage.example.com' to 'example.com' for evaluation.
  75. if(source.indexOf('.')==source.lastIndexOf('.')){
  76. //There is no more stuff to remove from search term.
  77. break;
  78. }
  79. else{
  80. //Anything in here is getting sliced and diced, lol
  81. source=source.slice(source.indexOf('.')+1,source.length);
  82. }
  83. }
  84. //Anything in here has a href attribute.
  85. if (source.search(loc) == -1) {
  86. //Anything at this level is not first party.
  87. if (whiteList != "") {
  88. //There is apparently a white list.
  89. if (whiteList.search(source) == -1) {
  90. //Anything in here is not in the white list.
  91. removed+='\n'+This.href+'\n';
  92. if (This.innerHTML) {
  93. This.innerHTML=note;
  94. }
  95. else {
  96. This.title=note;
  97. }
  98. This.style.display='none';
  99. This.href=null;
  100. }
  101. }
  102. else {
  103. //There is apparently no white list.
  104. removed+='\n'+This.href+'\n';
  105. This.title=note;
  106. This.href=null;
  107. }
  108. }
  109. }
  110. }
  111. }
  112. window.addEventListener("load", function(e) {
  113. for (i=0;i < document.getElementsByTagName('*').length;i++) {
  114. This = document.getElementsByTagName('*')[i];
  115. if (This.src) {
  116. //Anything in here has a src attribute.
  117. if (This.src.slice(0,4) !='data:'){
  118. //Anything in here is not a data uri.
  119. temp = document.createElement('a');
  120. temp.setAttribute('href',This.src);
  121. source = temp.hostname;
  122. for (x=0;x<=x+1;x++){
  123. //This changes stuff like 's2c.d.example.com' or 'sage.example.com' to 'example.com' for evaluation.
  124. if(source.indexOf('.')==source.lastIndexOf('.')){
  125. //There is no more stuff to remove from search term.
  126. break;
  127. }
  128. else{
  129. //Anything in here is getting sliced and diced, lol
  130. source=source.slice(source.indexOf('.')+1,source.length)
  131. }
  132. }
  133. //Anything in here has a search attribute.
  134. if (source.search(loc) == -1) {
  135. //Anything at this level is not first party.
  136. if (whiteList != "") {
  137. //There is apparently a white list.
  138. if (whiteList.search(source) == -1) {
  139. //Anything in here is not in the white list.
  140. removed+='\n'+This.src+'\n';
  141. if (This.innerHTML) {
  142. This.innerHTML=note;
  143. }
  144. else {
  145. This.value=note;
  146. }
  147. This.src=null;
  148. This.style.display='none';
  149. }
  150. }
  151. else {
  152. //There is apparently no white list.
  153. removed+='\n'+This.src+'\n';
  154. if (This.innerHTML) {
  155. This.innerHTML=note;
  156. }
  157. else {
  158. This.value=note;
  159. }
  160. This.src=null;
  161. This.style.display='none';
  162. }
  163. }
  164. }
  165. }
  166. }
  167. }, false);
  168. GM_registerMenuCommand("View a list of content removed by 'Third Party Content Remover'.", Removed);
  169. GM_registerMenuCommand("Add sites to 'Third Party Content Remover' White List.", add2List);

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址