Mad_Kiwi

Comfy Bread Q Script 2 - Q.js

Oct 4th, 2020
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* My Comfy Javascript been using for months now last updated 4/1/2019
  2. * q.js v2018.3-6.9
  3. * Added Blacklist NOPE button.
  4. * Replaced Q's trip !A6yxsPKia. to !!mG7VJxZNCI
  5. * Added Toastmaster from https://pastebin.com/eM106zgK
  6. * Mark previous bread links yellow
  7. */
  8. // User Settings
  9. var anonsw = {
  10. qflair: '', // Examples: REAL, →
  11. qcolor: '#ffc',
  12. youcolor: '#fcc',
  13. scrollcolor: 'rgba(153, 153, 153, 0.6)',
  14. scrollbackcolor: '#333',
  15. scrolltime: 400, // ms
  16. updateDelay: 200, // ms
  17. sidenavWidth: 30, // px
  18.  
  19. floodEnabled: true,
  20. floodThreshold: 15, // min # posts before beginning fade
  21. floodVanish: 25, // max # posts before completed fade/hide
  22. floodBehavior: 'fade', // hide, fade
  23. fadenametripregex: /^(Anon(ymous)?-.*|.*-!!mG7VJxZNCI)$/i,
  24. fadenametripfloodvalue: -1, // Effective post count for fading, or -1 for auto of floodThreshold+post count
  25. strikeThroughNameFags: true,
  26.  
  27. rateHistoryLen: 50, // Data points on chart
  28. rateAvgLen: 10 // Number of data points to average for instantaneous rate
  29.  
  30. // Suggestions from 589388.html#590283
  31. // ...shill detection features, such as
  32. // easily knowing the proportion of posts from a user that don't link.
  33. // I'd want to know any ID that was posting > 1/3 posts targetting noone.
  34.  
  35. // TODO: Behavior for post hover should be to show original post visual before all q.js mods
  36. // TODO: Add flags to turn on/off features
  37. // TODO: Custom-regex -> post color/fade (auto-filter by selecting text and choosing new menu item?)
  38. // Examples: daily reminder, guys, check this out, shill, get out, filtered, tell us more, archive everything
  39. // TODO: Manual shade
  40. // TODO: remove Q trip codes from post content?
  41. // TODO: remove Q from end of post content if not a Q post?
  42. // TODO: recognize all of known Q trip codes? (make to sure to exclude known comps)
  43. // TODO: Links to reset on current Q/(you) post
  44. // TODO: Link to go to latest post (end key doesn't always work, but try capturing that as well?)
  45. // TODO: Keyboard shortcuts for navigation
  46. // TODO: Current/Total overall post navigation
  47. // TODO: Remap end key to always go to end of page
  48. // TODO: Check box for each post to mark as "read", "spam", ?
  49. // TODO: Autocorrect all-caps posts (50% threshold)?
  50. // TODO: Correct broken links but remove referral when clicked?
  51. // TODO: Make flood post fading non-linear to give leniency to posters just passing flood threshold
  52. // TODO: Penalize reposts in flood detection (if id's different, merge?) ?
  53. // TODO: Scorecard of posters ordered by post count (post rate, reply count, ...)?
  54. // TODO: Color/shade posts where there are no references and no question marks
  55. // TODO: If Q or trip used in name field, strike them out or replace with Anonymous?
  56. // TODO: embedded posts in Q posts don't have background-color and inherit Q color, fix?
  57. };
  58. !function(t,$,n){var e,s,r,h,l=[],o=[],a=-1,c=[],d=-1,f=[],p=[],v=[];function g(t){$("html, body").animate({scrollTop:$(t).offset().top-$("div.boardlist").height()},anonsw.scrolltime)}function u(){return $(c).each(function(){$(this).css("background-color",anonsw.youcolor)}),$.Deferred().resolve()}function w(){return $('div.body:icontains("(You)")').each(function(){$(this).find(":not(small)").contents().filter(function(){return 3==this.nodeType}).each(function(){this.textContent=this.textContent.replace(/\(+ *You *\)+/gi,"you")})}),$.Deferred().resolve()}function y(){return $(o).each(function(t,n){$(n).css("background-color")!==anonsw.qcolor&&(""!==anonsw.qflair&&$(n).find("p.intro > label > span.trip").first().prepend(anonsw.qflair+" "),$(n).css("background-color",anonsw.qcolor))}),$.Deferred().resolve()}function m(){var t,n=-1;for(a>l.length&&(a=l.length),d>c.length&&(d=c.length),i=0;i<l.length;i++){var o=$(l).get(i);if(-1==n&&(n=$(o).css("font-size"),t=Math.floor(1.5*parseInt(n.replace("px","")))),$(o).offset().top+$(o).height()-2.25*t>$(window).scrollTop()){a=i;break}}for(i=0;i<c.length;i++){o=$(c).get(i);if(-1==n&&(n=$(o).css("font-size"),t=Math.floor(1.5*parseInt(n.replace("px","")))),$(o).offset().top+$(o).height()-2.25*t>$(window).scrollTop()){d=i;break}}$(".qcount").text("("+(a+1)+":"+l.length+")"),$(".youcount").text("("+(d+1)+":"+c.length+")")}function b(){var t=$("#sidenav");if(t.length){for($(t).css("height",$(window).height()-$("div.boardlist").height()),h=e.canvas.height/($(window).height()-$("div.boardlist").height()),e.clearRect(0,0,e.canvas.width,e.canvas.height),f=[],e.fillStyle=anonsw.qcolor,i=0;i<l.length;i++){var n=$(l).get(i);(o=$(n).height()/$(document).height()*e.canvas.height)<h&&(o=h),f[i]={x:s,y:$(n).offset().top/$(document).height()*e.canvas.height,width:e.canvas.width-2*s,height:o},e.fillRect(f[i].x,f[i].y,f[i].width,f[i].height)}for(p=[],e.fillStyle=anonsw.youcolor,i=0;i<c.length;i++){var o;n=$(c).get(i);(o=$(n).height()/$(document).height()*e.canvas.height)<h&&(o=h),p[i]={x:s,y:$(n).offset().top/$(document).height()*e.canvas.height,width:e.canvas.width-2*s,height:o},e.fillRect(p[i].x,p[i].y,p[i].width,p[i].height)}if(e.fillStyle=anonsw.scrollcolor,e.fillRect(r/2,$(window).scrollTop()/$(document).height()*e.canvas.height,r,$(window).height()/$(document).height()*e.canvas.height),750<$("#thread_stats_posts").text()){var a=8192/($(window).height()-$("div.boardlist").height());e.fillStyle="#f66",e.fillRect(0,e.canvas.height-a,e.canvas.width,a)}}}function x(){m(),b(),function(){var t=$("div.post").not(".post-hover"),n=t.length-(anonsw.rateHistoryLen+anonsw.rateAvgLen)+1;n<1&&(n=1),$($($(t).get(0)).find(".intro time").get(0)).attr("unixtime"),v=[],timehistory=[];for(var o=n;o<t.length;o++){var a=$($($(t).get(o)).find(".intro time").get(0)).attr("unixtime");if(timehistory[timehistory.length]=a,0<=timehistory.length-anonsw.rateAvgLen-1){var e=timehistory[timehistory.length-1],i=timehistory[timehistory.length-anonsw.rateAvgLen-1];v[v.length]=anonsw.rateAvgLen/((e-i)/60)}else v[v.length]=0}if($(".postRate").text(v[v.length-1].toFixed(1)),v.length>anonsw.rateAvgLen){var s=Math.max.apply(null,v),r=Math.min.apply(null,v);s-.5<r&&(r=s-.5,s+=.5),r<0&&(r=0);var h=timehistory[timehistory.length-1],l=timehistory[anonsw.rateAvgLen];$(".postRateChart").each(function(){var t=$(this).get(0).getContext("2d");t.clearRect(0,0,t.canvas.width,t.canvas.height),t.strokeStyle=$("div.boardlist a").css("color"),t.beginPath();var n=0,o=t.canvas.height-(v[anonsw.rateAvgLen]-r)/(s-r)*t.canvas.height;t.moveTo(n,o);for(var a=anonsw.rateAvgLen+1;a<v.length;a++)n=(timehistory[a]-l)/(h-l)*t.canvas.width,o=t.canvas.height-(v[a]-r)/(s-r)*t.canvas.height,t.lineTo(n,o);t.stroke(),t.closePath()})}}()}function _(){return c=$.map($('div.post:not(.post-hover) > p.intro > label span.name > span.own_post, div.post:not(.post-hover) > div.body > p.body-line > small:icontains("(You)")'),function(t){return $(t).closest("div.post")}),$.Deferred().resolve()}function T(){if(anonsw.floodEnabled){var e={},i=null,t=$("div.post:not(.post-hover)").not(".you");$(t).each(function(){var t,n=$(this).find("p > span.poster_id").first().text();if(null!=i){if(n in e||(e[n]={count:0,namefag:!1,floodcount:0}),e[n].count++,!e[n].namefag){var o=(t=$(this).find("p > label span.name").first()).contents().not(t.children()).text(),a=$(this).find("p > label > span.trip").first().text();e[n].namefag=!anonsw.fadenametripregex.test(o+"-"+a)}e[n].namefag?anonsw.fadenametripfloodvalue<0?e[n].floodcount=anonsw.floodThreshold+e[n].count:e[n].floodcount=anonsw.fadenametripfloodvalue:e[n].floodcount=e[n].count}null==i&&(i=n)}),$.each(e,function(t,n){if(t!==i){var o=$('span.poster_id:contains("'+t+'")');if(n.floodcount>anonsw.floodThreshold||n.namefag)if(anonsw.strikeThroughNameFags&&n.namefag&&$(o).each(function(){$(this).closest("div.post").find("p > label span.name").first().css("text-decoration","line-through")}),"fade"===anonsw.floodBehavior){var a=n.floodcount;a>anonsw.floodVanish&&(a=anonsw.floodVanish),(a=(anonsw.floodVanish-anonsw.floodThreshold-(a-anonsw.floodThreshold))/(anonsw.floodVanish-anonsw.floodThreshold))<.1&&(a=.1),$(o).each(function(){$(this).closest("div.post").css("opacity",a),$(this).closest("div.post").hover(function(){$(this).animate({opacity:1},anonsw.updateDelay)},function(){$(this).animate({opacity:a},anonsw.updateDelay)})})}else"hide"===anonsw.floodBehavior&&n.count>=anonsw.floodVanish&&$(o).each(function(){$(this).closest("div.post").hide()});else $(o).each(function(){$(this).closest("div.post").css("opacity",1)})}})}return $.Deferred().resolve()}function k(){(l=$.map($('div.post:not(.post-hover) > p.intro > label > span.trip:contains("!!mG7VJxZNCI")'),function(t){return $(t).closest("div.post")}),o=$.map($('div.post:not(.post-hover) > p.intro > label > span.trip:contains("!!mG7VJxZNCI")'),function(t){return $(t).closest("div.post")}),$.Deferred().resolve()).done(y).done(w).done(_).done(u).done(T).done(x)}!function($){var e,i=$.fn.on;$.fn.on=function(){var t=Array.apply(null,arguments),n=t[t.length-1];if(isNaN(n)||1===n&&t.pop())return i.apply(this,t);var o=t.pop(),a=t.pop();return t.push(function(){var t=this,n=arguments;clearTimeout(e),e=setTimeout(function(){a.apply(t,n)},o)}),i.apply(this,t)}}(this.jQuery||this.Zepto),$.expr[":"].icontains=jQuery.expr.createPseudo(function(n){return function(t){return 0<=jQuery(t).text().toUpperCase().indexOf(n.toUpperCase())}}),t.nextq=function(){0<l.length&&(a<l.length-1&&a++,g($(l).get(a)))},t.lastq=function(){0<l.length&&(a=l.length-1,g($(l).get(a)))},t.prevq=function(){0<l.length&&(0<a&&a--,g($(l).get(a)))},t.firstq=function(){0<l.length&&(a=0,g($(l).get(a)))},t.nextyou=function(){0<c.length&&(d<c.length-1&&d++,g($(c).get(d)))},t.lastyou=function(){0<c.length&&(d=c.length-1,g($(c).get(d)))},t.prevyou=function(){0<c.length&&(0<d&&d--,g($(c).get(d)))},t.firstyou=function(){0<c.length&&(d=0,g($(c).get(d)))},$(window).on("scroll",function(t){m(),b()},anonsw.updateDelay),$(window).on("resize",function(t){x()},anonsw.updateDelay),t.toggleFlood=function(){anonsw.floodEnabled?(anonsw.floodEnabled=!1,$(".toggleFloodState").text("On"),"fade"===anonsw.floodBehavior?$("span.poster_id").each(function(){$(this).closest("div.post").css("opacity",1),$(this).closest("div.post").off("mouseenter mouseleave")}):"hide"===anonsw.floodBehavior&&$(this).closest("div.post").show()):(anonsw.floodEnabled=!0,$(".toggleFloodState").text("Off"),k())},t.Q=function(){$("div.boardlist").append('<span>[ <a href="javascript:anonsw_main.firstq();"><i class="fa fa-step-backward"></i></a> <a href="javascript:anonsw_main.prevq();"><i class="fa fa-backward"></i></a> <span style="filter:brightness(70%);">Q</span> <span class="qcount">(?:?)</span> <a href="javascript:anonsw_main.nextq();"><i class="fa fa-forward"></i></a> <a href="javascript:anonsw_main.lastq();"><i class="fa fa-step-forward"></i></a> ]</span>'),$("div.boardlist").append('<span>[ <a href="javascript:anonsw_main.firstyou();"><i class="fa fa-step-backward"></i></a> <a href="javascript:anonsw_main.prevyou();"><i class="fa fa-backward"></i></a> <span style="filter:brightness(70%);">(You)</span> <span class="youcount">(?:?)</span> </span><a href="javascript:anonsw_main.nextyou();"><i class="fa fa-forward"></i></a> <a href="javascript:anonsw_main.lastyou();"><i class="fa fa-step-forward"></i></a> ]</span>'),$("div.boardlist").append('<span>[ <a href="javascript:anonsw_main.toggleFlood();">Turn Post Fading <span class="toggleFloodState">Off</span></a> ]</span>'),function(){var n=$("div.boardlist").height()-1;$("div.boardlist").append('<span>[ Post Rate: <span class="postRate">0</span> posts/min <canvas class="postRateChart"></canvas>]</span>'),$(".postRate").css("color",$("div.boardlist a").css("color"));var t=$(".postRateChart");$(t).each(function(){$(this).css("width","100px"),$(this).css("height",n),$(this).css("vertical-align","middle");var t=$(this).get(0).getContext("2d");t.canvas.height=20,t.canvas.width=100})}(),function(){$("body").append('<canvas id="sidenav"></canvas>');var t=$("#sidenav");$(t).css("position","fixed"),$(t).css("top",$("div.boardlist").height()),$(t).css("right",0),$(t).css("width",anonsw.sidenavWidth),$(t).css("height",$(window).height()-$("div.boardlist").height()),$(t).css("background-color",anonsw.scrollbackcolor),$("body").css("margin-right",anonsw.sidenavWidth),(e=$("#sidenav").get(0).getContext("2d")).canvas.height=2048,e.canvas.width=anonsw.sidenavWidth,s=1,r=e.canvas.width/2}(),k();var t=$("div.thread")[0];new MutationObserver(function(t){for(var n in t)if("childList"==t[n].type){k();break}}).observe(t,{childList:!0})}}(window.anonsw_main=window.anonsw_main||{},jQuery),$(document).ready(anonsw_main.Q);
  59.  
  60. /*
  61. * Toastmaster 1.1.0
  62. * Finds the bread so you don't have to.
  63. * Also tries to stop you from posting in a locked thread.
  64. *
  65. * Always read the code before pasting it.
  66. */
  67.  
  68. /* this is literally just a picture of toast */
  69.  
  70. var toast ="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABsAAAAbCAMAAAC6CgRnAAAARVBMVEWZMwAAAABmMwBmMzNmZjOZZgCZZjOZZmbMZgDMZjPMZmaZmTOZmWbMmTPMmWbMmZn/mWbMzGbMzJn/zGb/zJn/zMz//8zDFCa2AAAAAXRSTlMAQObYZgAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB+IIBAI4ECHmtE4AAAFKSURBVCjPVVIBcsMwCKubQuZb0J2xu/8/dRJJt5ZzcnGEhAy+3V7R3uL2FtrfffN927a7P+7tDYEDuRiZ4II/LrQ5EQwQKVAp8HZCBu6Jrpm5JpiST+ytBGFBovIrB5iDX3RECCKKh+SDSoxEYaYtWVEkhkdgCluBTmIO2kHwr015m6mCqROMkMwsOcjOurwERYbcpBDrgfyBsPpDMVHLiVTYifJ5sEiWKs6FoLtRPo+ijXI4aazzvGEvrHJXnAcgyi9bwiyrm8mKKUCS5IJnaPFfpXrHWt27xyqsV8Fuhu5yadHDIcy+7eKxWVaaqKyz15IHaWFfTjkhvTQpEp1pxmWdc+aL7D/M1F1a57l6KIGwNPuCrOZ5tlVvCsU4edX6+he8E+xY5bWaA0eX6+BgBq/SwfGz/2EahAbLGgd8Z/92v0JD+rjQH/ELBU8elOTZkAQAAAAASUVORK5CYII=";
  71.  
  72. function navigate(url) {
  73. if(typeof url != 'undefined') {
  74. window.location.href=url;
  75. }
  76. }
  77.  
  78. function get_bread_number(text) {
  79. if ( (text.toLowerCase().indexOf('ebake') != -1)
  80. || (text.toLowerCase().indexOf('q research') != -1)) {
  81. var rx = /[^0-9]*([0-9]+)[^0-9]*/g;
  82. var arr = rx.exec(text);
  83. return arr && arr.length > 1 ? arr[1] : false;
  84. }
  85.  
  86. return false;
  87. }
  88.  
  89.  
  90. function make_toast(url, time) {
  91.  
  92. var response;
  93.  
  94. var age = 100 - ((~~((new Date).getTime() / 1000)) - time)/72;
  95.  
  96. var x = new XMLHttpRequest();
  97. x.open('GET', url, true);
  98.  
  99. x.onreadystatechange = function() {
  100. if(x.readyState === 4 && x.status == 200) {
  101. response = JSON.parse(x.responseText);
  102.  
  103. var target = document.getElementById('dythreads');
  104.  
  105. var bread = response.posts[0];
  106. var posts = response.posts.length;
  107. var txt = bread.sub;
  108. if (typeof txt == 'undefined') {
  109. txt = bread.com;
  110. if (txt.length > 40) {
  111. txt = txt.substring(0,39) + '...';
  112. }
  113. }
  114. var num = get_bread_number(txt);
  115. if (false == num) return;
  116. var thread = document.getElementsByName('thread');
  117.  
  118. console.log('thread ' + thread[0].value + ' ' + bread.no)
  119. if (thread[0].value == bread.no) {
  120. var pfi = document.getElementById('post-form-inner');
  121. console.log('ok');
  122. if (pfi && (posts > 750)) {
  123.  
  124. pfi.style.padding='3px';
  125. pfi.style.border='3px solid red';
  126. pfi.style.borderRadius='10px';
  127. pfi.style.opacity='0.7';
  128. pfi.style.background='url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAYAAACp8Z5+AAAAGklEQVQIW2NkYGD4D8SMQAwGcAY2AbBKDBUAVuYCBQPd34sAAAAASUVORK5CYII=) repeat';
  129.  
  130. }
  131. }
  132.  
  133. var opts = document.getElementsByName('toast');
  134.  
  135. for(var i = 0; i < opts.length; i++) {
  136. if (opts[i].getAttribute('no') == bread.no) {
  137. opts[i].setAttribute('old',false)
  138. opts[i].setAttribute('title', txt + ' (' + posts + ')' );
  139.  
  140. return;
  141. }
  142. }
  143.  
  144.  
  145. var img = document.createElement('IMG');
  146.  
  147. var opt = document.createElement('SPAN');
  148.  
  149. opt.setAttribute('title', txt + ' (' + posts + ')' );
  150. opt.setAttribute('no',bread.no);
  151. opt.style.borderRadius='5px';
  152. opt.style.border='1px solid transparent';
  153.  
  154. opt.addEventListener('mouseover',function() {
  155. opt.style.backgroundColor='rgb(255,255,255,0.4)';
  156. opt.style.cursor='pointer';
  157. });
  158.  
  159. opt.addEventListener('mouseout',function() {
  160. opt.style.backgroundColor='transparent';
  161. opt.style.cursor='auto';
  162. });
  163.  
  164. opt.style.height = '39x';
  165. opt.style.width = '35px';
  166. opt.style.verticalAlign='top';
  167. opt.style.textAlign='center';
  168. opt.style.display = 'inline-block';
  169.  
  170. img.src = toast;
  171. img.id = "" + bread.no;
  172.  
  173. opt.appendChild(img);
  174. target.appendChild(opt);
  175.  
  176. opt.setAttribute('name','toast');
  177.  
  178. var label = document.createElement('SPAN');
  179. label.style.display = 'block';
  180. label.style.fontWeight = 'bold';
  181. label.style.fontSize = '11px';
  182. var node = document.createTextNode(num);
  183. label.appendChild(node);
  184. opt.appendChild(label);
  185.  
  186. img.style = "filter: saturate(" + age + "%);";
  187. img.style = "filter: brightness(" + age + "%);";
  188.  
  189. opt.onclick = function () {
  190. var no = bread.no;
  191. return navigate("/qresearch/res/" + no + ".html");
  192. };
  193.  
  194. opt.setAttribute('old',false);
  195. }
  196. };
  197. x.send();
  198.  
  199. }
  200.  
  201. // every 60 seconds we reload from threads.json
  202. function refresh() {
  203. var opts = document.getElementsByName('toast');
  204.  
  205. // prune expired breads and append new ones.
  206. if (typeof opts != 'undefined') {
  207. for(var i = 0; i < opts.length; i++) {
  208. if(opts[i].getAttribute('old') == true) {
  209. target.removeChild(opts[i]);
  210. console.log('removed option ' + i)
  211. }
  212. else {
  213. opts[i].setAttribute('old',true);
  214. }
  215. console.log(opts[i].getAttribute('old'));
  216. }
  217. }
  218. else {
  219. console.log('no opts');
  220. }
  221.  
  222. var x = new XMLHttpRequest();
  223. x.open('GET', "/qresearch/threads.json", true);
  224. x.onreadystatechange = function() {
  225. if(x.readyState === 4 && x.status == 200) {
  226. var response = JSON.parse(x.responseText);
  227. find_recent_bread(response);
  228. }
  229. };
  230. x.send();
  231.  
  232.  
  233. }
  234.  
  235. function find_recent_bread(board) {
  236.  
  237. var now = ~~((new Date).getTime() / 1000);
  238. var thread;
  239. for(var i = 0; i < board.length; i++) {
  240. for(var j = 0; j < board[i].threads.length; j++) {
  241. thread = board[i].threads[j];
  242. // only show threads modified within the last 2 hours
  243.  
  244. if (now - thread.last_modified < 7200) {
  245. make_toast('/qresearch/res/'+thread.no + '.json',
  246. thread.last_modified);
  247. }
  248.  
  249. }
  250. }
  251. }
  252.  
  253. var target = window.top.document.getElementsByName('postcontrols')[0];
  254.  
  255. // Post controls is loaded and we're already in a thread
  256. // append the controls at the top, but only once.
  257. var dythreads = window.top.document.getElementById('dythreads');
  258. if (target && ! dythreads) {
  259.  
  260. var div = document.createElement('DIV');
  261. div.id = 'dythreads';
  262. target.appendChild(div);
  263.  
  264. div.style
  265. = 'z-index:2;'
  266. + 'top:20px; width:15%; position:fixed; height:1px;'
  267. + 'right:20px; display:block;';
  268.  
  269. setInterval("refresh();", 30000);
  270. refresh();
  271. }
  272.  
  273. /* Display a replies counter overlay in the bottom right corner */
  274. $(function(){
  275. $('head').append('<style>#thread_stats_posts_ovl { '+
  276. 'position:fixed;bottom:15px;right:35px;'+
  277. 'font:38px sans-serif;opacity:0.5;color:#f60;}</style>');
  278. $('body').append('<div id="thread_stats_posts_ovl"/>');
  279. function copyStats() { $('#thread_stats_posts_ovl').
  280. text($('#thread_stats_posts').text());}
  281. $(document).on('new_post',copyStats); copyStats();});
  282.  
  283. /* NOPE */
  284. var imageBlacklist = [] ;
  285. function loadImageBlacklist() { JSON.parse(localStorage.imageBlacklist || "[]").forEach(addToImageBlacklist); }
  286. function saveImageBlacklist() { localStorage.imageBlacklist = JSON.stringify(imageBlacklist); }
  287. function addToImageBlacklist(md5) { if (md5 && -1 === imageBlacklist.indexOf(md5)) imageBlacklist.push(md5); }
  288. function removeImageFromBlacklist(md5) { var index = imageBlacklist.indexOf(md5); if (-1 !== index) imageBlacklist.splice(index, 1); }
  289. function blacklistPostImages(post) { $(post).find('img.post-image').each(function (i, el) { var md5 = el.getAttribute('data-md5'); addToImageBlacklist(md5); $(el).addClass('nope'); }); }
  290. function removeBlacklistedImages() { $('img.post-image').each(function (i, el) { if (-1 !== imageBlacklist.indexOf(el.getAttribute('data-md5'))) { $(el).addClass('nope'); } }); }
  291. function onNopeClicked(event) { event.preventDefault(); event.stopPropagation(); loadImageBlacklist(); var post = $(event.target).closest('.post'); blacklistPostImages(post); removeBlacklistedImages(); saveImageBlacklist(); }
  292. function addNopeButtons() { $('.post').each(function(i, post) { if ($(post).find('.nope').length === 0) { $(post).prepend("<input type='button' class='nope' onClick='onNopeClicked(event)' value='Nope'></input>"); } }) }
  293. setInterval(function () { loadImageBlacklist(); removeBlacklistedImages(); addNopeButtons(); }, 1000);
  294. $('body').on('click', 'img.nope', function (event) { event.preventDefault(); event.stopPropagation(); $(this).removeClass('nope'); removeImageFromBlacklist(this.getAttribute('data-md5')); saveImageBlacklist(); });
  295. /* end NOPE */
  296.  
  297. /* Mark Previous Bread Links Yellow */
  298. var postId = window.location.href.match(/\/(\d+)\.html/)[1];
  299. var style = document.createElement('style');
  300. style.innerHTML = `
  301. a[href^="/qresearch/res/"]:not([href^="/qresearch/res/${postId}.html"]) {
  302. background: #ffb;
  303. }
  304. `;
  305. document.querySelector('head').appendChild(style);
  306. /* end Mark Previous Bread Links Yellow */
Add Comment
Please, Sign In to add comment