NordBaker

toastmaster + nope

May 5th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.06 KB | None | 0 0
  1. /* Enter your own Javascript code here... */
  2. /* You can include JS files from remote servers, for example: */
  3. /* load_js("http://example.com/script.js"); */
  4. /* Enter your own Javascript code here... */
  5. /* You can include JS files from remote servers, for example: */
  6. /* load_js("http://example.com/script.js"); */
  7.  
  8. //================================================================
  9. //
  10. // Toastmaster 2.5.6
  11. // Finds the bread so you don't have to.
  12. //
  13. // Always look through the code to find shifty stuff.
  14. //
  15. //
  16. //================================================================
  17. //2345678901234567890123456789012345678901234567890123456789012345
  18. /*
  19. these files can be extracted and saved as text and they should
  20. still be loadable
  21. */
  22. var chatty = true; // set me to false if you don't want to hear me
  23. window.t = 0;
  24. var container;
  25. /* this is literally just a picture of toast */
  26.  
  27. var toast = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABsAA"
  28. + "AAbCAMAAAC6CgRnAAAARVBMVEWZMwAAAABmMwBmMzNmZjOZZgCZ"
  29. + "ZjOZZmbMZgDMZjPMZmaZmTOZmWbMmTPMmWbMmZn/mWbMzGbMzJn"
  30. + "/zGb/zJn/zMz//8zDFCa2AAAAAXRSTlMAQObYZgAAAAlwSFlzAA"
  31. + "ALEwAACxMBAJqcGAAAAAd0SU1FB+IIBAI4ECHmtE4AAAFKSURBV"
  32. + "CjPVVIBcsMwCKubQuZb0J2xu/8/dRJJt5ZzcnGEhAy+3V7R3uL2"
  33. + "FtrfffN927a7P+7tDYEDuRiZ4II/LrQ5EQwQKVAp8HZCBu6Jrpm"
  34. + "5JpiST+ytBGFBovIrB5iDX3RECCKKh+SDSoxEYaYtWVEkhkdgCl"
  35. + "uBTmIO2kHwr015m6mCqROMkMwsOcjOurwERYbcpBDrgfyBsPpDM"
  36. + "VHLiVTYifJ5sEiWKs6FoLtRPo+ijXI4aazzvGEvrHJXnAcgyi9b"
  37. + "wiyrm8mKKUCS5IJnaPFfpXrHWt27xyqsV8Fuhu5yadHDIcy+7eK"
  38. + "xWVaaqKyz15IHaWFfTjkhvTQpEp1pxmWdc+aL7D/M1F1a57l6KI"
  39. + "GwNPuCrOZ5tlVvCsU4edX6+he8E+xY5bWaA0eX6+BgBq/SwfGz/"
  40. + "2EahAbLGgd8Z/92v0JD+rjQH/ELBU8elOTZkAQAAAAASUVORK5C"
  41. + "YII=";
  42.  
  43. /* this is an MP3 file. you should inspect it yourself */
  44. var frog = "data:audio/wav;base64,UklGRjkKAABXQVZFZm10IBAAAAABA"
  45. + "AEAQB8AAEAfAAABAAgAZGF0YRUKAAB9fn1+gIGDhIOAf4B/gH+B"
  46. + "goGCgYKBf4CAf4B/gIGDgoGCf4B+foGCgYKBfnx9f3+AgoGCgoK"
  47. + "Af35/gYB/f4B/foKDhIOEg398fYB+fH6BgoGCgX9+foGCgYKCgH"
  48. + "17e3yAhISCgYOEg4GAfHuAg4SDgH+BgoGBg4aEf31/f3x8foB9e"
  49. + "XuAgoCAg4aFgoF+e3p8f4B8foOBf4GEgn6Ag4N+f4SDe3d+gn1+"
  50. + "h4h8e4aLh4GDhoB4eoB+eX6HhXx8g4R8fIODgX+Cgnp3foF8fYS"
  51. + "Ggn+BgHp4en6Af4CBf4GEgoCCh4V+en2CgX6DiYh+eH6BfICMjo"
  52. + "J4eXl4gIuLhIGDfnV7hYeDhYh9b3F9gn+Bh4Z7dX+Ef3+Lint0f"
  53. + "YN8e4SFeniDiYB5g4d/foaEdnqJjH58iId4eIaGeHqIhXR1hYh6"
  54. + "dn+Ce3qFiod9d4CGgnp+hYF5e4WHgYGHhHd2goiDg4uNf3iBhHt"
  55. + "7iZCDdnl8dneGjYF3fHtzdIKKhH+Afnd0eoOFfXd+iIN7hY2Acn"
  56. + "aEiImPjn1rboCTlo+Gdm5veIuYmY59Z11shJaenIVnX2NqgZ2fi"
  57. + "315bGV4kIp2f457aH2UgmyDnodqe5WCaIKkjGVymIxjcaCdbWSN"
  58. + "l25gi6aFYXWUelx8p5RocJiKXWidqHdghp1zWIKumWlumJNiYJe"
  59. + "vfll9m3FTga2NWG+ce1F5sp5kaZiDV3avr3lohXVQZp6ynYmBal"
  60. + "xxhYSOoZRwbY6KYGiXlm1/r5RbZY95V4i+oF9hinJMe7mra2KFa"
  61. + "Ul6urBwZIpyTXu1omVxpIhYdq2RV26upGJjoJ1bWZ61d1SKqW1M"
  62. + "jsSVUG2jdUN8w6FQXpx7RXnAolhtoHRMgbyfZXqZZEByqJFniKl"
  63. + "+W3mcmXxodIeAfpmfeWJ6kIZ/lJl5a4WTeWuEknZmgZN6aIKPaF"
  64. + "WApI1uhplwW3ySfH6qsYBda3VoeKi1hmJ0fVxinrKCapScbGuil"
  65. + "1RUj5ZkdLqsWkR9lWhzvrlrVH99T2u2uHNeh4VXZaOhZWWel1xi"
  66. + "oZtWXa29dWChqVpSqs6DSoKlWDWLxoVIeJhOO5rYnFaDqGIzcLe"
  67. + "mboGwj19xloRedqKMYnmSX0WJwphnkK9sNXC+o15ynntdfpaLf3"
  68. + "yAhIF/gIOCfnt+gH9/gYKBgoF+e32BgX+Af4GCgYKBgoGBgoGCg"
  69. + "YKAf4B/gH+BgX+Af4CBg4SGhIKBgoF/gYKCgH1/gYKBgoGCfnuA"
  70. + "goB/gYJ+f3+BgoKEgoF/gH+AgoGCgoB/fX6Af4CCgn99f4B/gIG"
  71. + "CgX+BgoGAf4GCgYKBgoF/gYKDgYCDg397fYB/f4GFhoSBfnx7fX"
  72. + "+AgYODhIKBf4B/e32AgoF/gH97foGAgH+BgX+AgYKBgoSDgYKBg"
  73. + "oGAgoKAgYKAf4CDhYOCf319foCBgX1+gYF/gISGg4GBgn19gYB/"
  74. + "gIJ/e36BgYB+f35+gICCgoGAgYJ/e36CgH5/g4J/gYKEgn+Bg4O"
  75. + "AgIOEgX+BgoGCgYOBfH+CgHt9g4WBfICDg35/gYB/foGEg4B9e3"
  76. + "p9goGAhIiFe3d7gIOEg4GAf4GBfX+CgX9+gYF8foWGgHt/gn58g"
  77. + "IOBf4GBfH2DhYJ/gYSBe32AfnyChIKEhoN/gYKBf4KGgnp7fXp8"
  78. + "hYeBgIJ/en2Fgnl4g4eCg4R+eHh+goGCgoWBeHl/gHx/h4J3eIG"
  79. + "DgIOGgX6EiH58h42Een2CgHp4gIaAf4ySgW51h4h+goqDdnuJgW"
  80. + "1zjI97eIyPeXB6f3l5hox/dHuEfXeBh4J9gH55fYKDhIN9eoKDf"
  81. + "ICIgXd8iIZ6f4yOgnyChX17h4qCeYCGfnuChH13eX+Dg4F+f4B9"
  82. + "fYB8e4GGfnmAg3x4e3p0d4aHfnyCgXuAiIR4eoJ7dX+PlI6Ig3l"
  83. + "ydYGHhoyVi3dvdHZ3g5GUi4WFgXpyamx+j42CiJOEbGlxb3CKoJ"
  84. + "V9eXxpW22LkomPn5NxY292bG+Rr6qNfIJ8XU1qlaWXhpGcgllSc"
  85. + "4uIiZGIdXqAbnKQlXlrhZiBaniQh3J6jo57doGIgHZ7g4F6f4uM"
  86. + "gHJ5g4J8g4p8bnaGgXmEjHlqeox+b36RhG58kol0f5eLcHaPjnp"
  87. + "/lIxsYnWBfYuhoIFoZmVqg6GkkIB2ZGCAnY9xd5F+X3Gbl2xpjI"
  88. + "llcJ+gc2KEh2Jon7CBXX6WbVmJr4lfgKaAV3upiVd2rZpgZ6CUV"
  89. + "2GjomNblZFUY6mxb16YjlRprrR2aJKFVWCUooN6lIdfZYeNd3eP"
  90. + "jGtmiZd2ZIOYd1+GsZhgYpCOW2Kit4NagJ9zUYK2mmB1qYtQaKe"
  91. + "TTlylrWhPjaVfSpHBi054pW1Hg76kZnadd0xroqZ/fJmEX2mIjo"
  92. + "iHgXl3eXl6hIyFeHV7d293hod6eIWGeHSFjoJ2foiBfIeQhnl7h"
  93. + "IJ/hIiGgn1ya3qTlYd/gHVibJCei3qHimhRbZOThJKihF1jgoBo"
  94. + "d5+fc2OIl2xUf6KAX4q4k1tnkn9VdLKscWeXkVRZmqtzYJ6saE+"
  95. + "JnFxNlb2FUH+naD+AxLFnb6J6QFibr4FslpZmYoWXj4J7gIZ8bG"
  96. + "t8ioiFjZF5YW2Ff2p6m49nbpqVYFiFmHNporqEVW+PaVSUx6Bjd"
  97. + "aB4RW+xnF1yt6VXUpWcTkSYxotKeahkK2nDznpYlY9KRYSwlXOK"
  98. + "lnBgfZOPiIN7dneBioiCg4aAc292g4N4dYGIgHl9hH1ydIOLgny"
  99. + "GiXpzgY2BdoOZmYBvfI6MeHOEhWhbe52YhIOPfVlTb4WGjqGhe1"
  100. + "Zcen9zi66heHaQf1JVh5V2fq+yeFRjbFNjqsmgcoCDUE2QuI9sn"
  101. + "bp7RGCUdUBuv712Xo2HOz+e2KhfgqVhMWaxqXJ4n4BVbJGVhoKH"
  102. + "hHp3fIGEhoJ+fHx2cHJ2dnV+i46GhIuJd2pxfoCBjJiRgXx+end"
  103. + "9io+Dd4CSlIh5cnBjW26MlpGTloRhUWeHg3qXtJtpYHmAamqLm4"
  104. + "qEmJBlV298am2dwKZwZnprTWyzwpWBnpNSPXSbcFWb2adTUYVoJ"
  105. + "FzS8ZlVgY5AJXS7pG6Do31cdZeUhn55e4OLioODiYd9dXd7f4KF"
  106. + "hYSBenNxdnh3eH+Ki4WBgn54en6AgomSkIiDhIJ7dnd8f4KKlJe"
  107. + "Qf29pYVtke5ajnIRtYF9sgY2Up7amhG5tbGNpjq2lj4N1VzY9a4"
  108. + "yZtNzPgUtMUD5QpOXSloeFUjBelH1zvNOAQnKaPQV/9+GCf8Z7A"
  109. + "BOo5oNkoqVTRIejkn94e4aLiYSFjIt+cm5wdHV6hIaCg4iLgnV3"
  110. + "gn98jJuWhH+CfGtkeI+NfX2RnZJ7bWtjYX6aknqAmpd6Y2h2fYi"
  111. + "ZopN/eoB6aWiAjoiLnqGDZGZza197q7WYhox9T0F6rJh7nruGRF"
  112. + "mafCZM1emXa621OgBB39mPi6eeXE1vioV/gYGAf4CAgoF/gH+Bg"
  113. + "oB/";
  114.  
  115. function _i(o) {
  116. return (o) ? document.getElementById(o) : null;
  117. }
  118. function _n(o) {
  119. return (o) ? document.getElementsByName(o) : [];
  120. }
  121. function _t(o) {
  122. return (o) ? document.getElementsByTagName(o) : [];
  123. }
  124. function _$(o) {
  125. return (o) ? document.getElementsByClassName(o): [];
  126. }
  127.  
  128. function _c(ob,id) {
  129. switch(ob) {
  130. case 'DIV':
  131. case 'SPAN':
  132. case 'INPUT':
  133. var ob = document.createElement(ob);
  134. ob.id = id;
  135. break;
  136. case 'LABEL':
  137. var ob = document.createElement(ob);
  138. ob.setAttribute('for', id);
  139. break;
  140. default:
  141. ob.appendChild(document.createTextNode(id));
  142. }
  143. return ob;
  144. }
  145.  
  146. function css(s, j) {
  147. for(var k in j) {
  148. s.style[k] = j[k];
  149. }
  150. }
  151.  
  152. function filter_by_id() {
  153. var id = _i('search_input').value;
  154. var list = _$('poster_id');
  155. var node;
  156. var valid;
  157. for(var i = 0; i < list.length; i++) {
  158. node = (list[i].parentNode.parentNode);
  159. valid = (-1 == node.innerText.indexOf(id));
  160. node.style.display=(valid)?'none':'inline-block';
  161. if (node.nextSibling) {
  162. node.nextSibling.style.display=(valid)?'none':'inline';
  163. }
  164. }
  165. }
  166.  
  167. function get_bread_number(text) {
  168. if ( (text.toLowerCase().indexOf('ebake') != -1)
  169. || (text.toLowerCase().indexOf('q research general') != -1)) {
  170. var rx = /[^0-9]*([0-9]+)[^0-9]*/g;
  171. var arr = rx.exec(text);
  172.  
  173. return arr && arr.length > 1 ? arr[1] : false;
  174. }
  175.  
  176. return false;
  177. }
  178. window.colored = 0;
  179. window.all_breads = {};
  180.  
  181. function make_toast(url, time) {
  182.  
  183. var response;
  184. var x = new XMLHttpRequest();
  185. x.open('GET', url, true);
  186.  
  187. if (typeof window.all_breads[url] == 'undefined') {
  188. window.all_breads[url] = 0;
  189. }
  190. if (window.all_breads[url] > 751 || window.all_breads[url] == -1) {
  191. return;
  192. }
  193. if (url == '#') {
  194. var opt = _c('SPAN', "ribbit");
  195.  
  196. var container = _i('dythreads');
  197.  
  198. var colors = ["#fefefe", "green", "red"];
  199.  
  200.  
  201. css(opt,{
  202. font : 'normal normal bold 8px/15px '
  203. + '"Courier New", Courier, Monospace',
  204. float : 'right',
  205. color : colors[1],
  206. cursor : 'pointer',
  207. width : '49px',
  208. height : '13px',
  209. margin : '1px',
  210. border : '1px solid #b0b0b0',
  211. display : 'inline-block',
  212. filter : 'brightness(100%)',
  213. textAlign : 'left',
  214. textIndent : '9px',
  215. borderRadius : '3px',
  216. verticalAlign : 'top',
  217. backgroundSize : '13px'
  218. });
  219.  
  220. opt.innerHTML = "RIBBIT!"
  221. + " <span style='font-weight:bold;color:"
  222. + colors[2]
  223. + ";'>"
  224. + "</span>";
  225.  
  226.  
  227. container.appendChild(opt);
  228.  
  229. opt.onclick = function () {
  230. var snd = new Audio(frog);
  231. snd.play();
  232. };
  233. return;
  234. }
  235. else x.onreadystatechange = function() {
  236. var that = url;
  237.  
  238. if(x.readyState === 4 && x.status == 200) {
  239.  
  240. response = JSON.parse(x.responseText);
  241.  
  242. var container = _i('dythreads');
  243.  
  244. var bread = response.posts[0];
  245. var posts = response.posts.length;
  246. var txt = bread.sub;
  247. window.all_breads[url] = posts;
  248. if (typeof txt == 'undefined') {
  249. txt = bread.com;
  250. if (txt.length > 40) {
  251. txt = txt.substring(0,39) + '...';
  252. }
  253. }
  254. var num = get_bread_number(txt);
  255. window.breadno = num;
  256. // skip this bread forever
  257. if (false == num) {
  258. window.all_breads[that] = -1;
  259. return;
  260. }
  261.  
  262. var thread = _n('thread');
  263. var hrefs = _t('A');
  264. if (thread && thread.length)
  265. for(var i = window.colored; i < hrefs.length; i++) {
  266.  
  267. if (-1 == hrefs[i].href.indexOf("res/" + thread[0].value+".html") &&
  268. -1 != hrefs[i].href.indexOf("qresearch")) {
  269. hrefs[i].style.color='#0077aa';
  270. window.colored = i; // don't color it twice.
  271. }
  272. }
  273.  
  274. if (thread && thread.length && thread[0].value == bread.no) {
  275. var pfi = _i('post-form-inner');
  276.  
  277. if (pfi && (posts > 750)) {
  278. css(pfi,{
  279. border :'3px solid red',
  280. padding :'3px',
  281. opacity : '0.7',
  282. background : 'url(data:image/png;base64,iVB'
  283. + 'ORw0KGgoAAAANSUhEUgAAAAQAAAAE'
  284. + 'CAYAAACp8Z5+AAAAGklEQVQIW2NkY'
  285. + 'GD4D8SMQAwGcAY2AbBKDBUAVuYCBQ'
  286. + 'Pd34sAAAAASUVORK5CYII=) repeat',
  287. borderRadius : '10px',
  288. });
  289. }
  290. }
  291.  
  292. var opts = _n('toast');
  293. if(! thread || ! thread.length) {
  294. var colors = ["#fefefe", "green", "red"];
  295. }
  296. else {
  297. var colors = ((thread[0].value == bread.no)
  298. ? ((posts < 750)
  299. ? ["#04ae04", "white", "black"]
  300. : ["#ae0404", "white", "black"])
  301. : ["#fefefe", "green", "red"]);
  302. }
  303. for(var i = 0; i < opts.length; i++) {
  304. if (opts[i].getAttribute('no') == bread.no) {
  305. opts[i].innerHTML = num
  306. + " <span style='font-weight:bold;color:"
  307. + colors[2]
  308. + "'>"
  309. + posts
  310. +"</span>";
  311.  
  312. opts[i].style.background = colors[0]
  313. + " url("
  314. + toast
  315. + ") 0px 0px/25px 25px no-repeat";
  316.  
  317. opts[i].style.backgroundSize = "13px";
  318.  
  319. return;
  320. }
  321.  
  322. }
  323.  
  324. var opt = _c('SPAN', "" + bread.no);
  325.  
  326. opt.setAttribute('no',bread.no);
  327.  
  328. opt.addEventListener('mouseout',function() {
  329. css(opt,{
  330. cursor : 'pointer',
  331. filter : 'brightness(100%)'
  332. })
  333. });
  334.  
  335. opt.addEventListener('mouseover',function() {
  336. css(opt,{
  337. cursor : 'auto',
  338. filter : 'brightness(80%)'
  339. })
  340. });
  341.  
  342. css(opt,{
  343. font : 'normal normal bold 8px/15px '
  344. + '"Courier New", Courier, Monospace',
  345. float : 'right',
  346. color : colors[1],
  347. width : '59px',
  348. height : '13px',
  349. margin : '1px',
  350. border : '1px solid #b0b0b0',
  351. display : 'inline-block',
  352. filter : 'brightness(100%)',
  353. textAlign : 'left',
  354. textIndent : '18px',
  355. background : colors[0] + ' url(' + toast
  356. + ') 0px 0px/25px 25px no-repeat',
  357.  
  358. borderRadius : '3px',
  359. verticalAlign : 'top',
  360. backgroundSize : '13px'
  361. });
  362.  
  363. opt.innerHTML = num
  364. + " <span style='font-weight:bold;color:"
  365. + colors[2]
  366. + ";'>"
  367. + posts
  368. + "</span>";
  369.  
  370. opt.id = "" + bread.no;
  371.  
  372. container.appendChild(opt);
  373.  
  374. opt.setAttribute('name','toast');
  375.  
  376. opt.onclick = function () {
  377. var no = bread.no;
  378. if(typeof url != 'undefined') {
  379. window.location.href =
  380. '/qresearch/res/' + no + '.html';
  381. }
  382. };
  383.  
  384. opt.setAttribute('old',false);
  385. }
  386. };
  387. x.send();
  388.  
  389. }
  390.  
  391. // every 60 seconds we reload from threads.json
  392.  
  393. function refresh() {
  394. // prune expired breads and append new ones.
  395. var opts = _n('toast');
  396.  
  397. for(var i = 0; i < opts.length; i++) {
  398. if (opts[i].getAttribute('old') == true) {
  399. container.removeChild(opts[i]);
  400.  
  401. }
  402. else {
  403. opts[i].setAttribute('old',true);
  404. }
  405. }
  406.  
  407. var x = new XMLHttpRequest();
  408. x.open('GET', "/qresearch/threads.json", true);
  409. x.onreadystatechange = function() {
  410. if(x.readyState === 4 && x.status == 200) {
  411.  
  412. var response = JSON.parse(x.responseText);
  413. find_recent_bread(response);
  414. }
  415. };
  416. x.send();
  417. trips();
  418.  
  419.  
  420. }
  421. window.qcount = 0;
  422. // Count instances of Q with trips, mark untripped Q's as fakes
  423. function trips() {
  424. var m = _i('notify');
  425. var t = 0;
  426. var k, r;
  427. var list = _$('trip');
  428. for(var i = 0; i < list.length; i++) {
  429. r = list[i].innerText.trim();
  430. if (list[i].parentNode.parentNode.className !='intro') continue;
  431. if (! r.length || r == 'FAKE') {
  432. continue;
  433. }
  434. k = list[i].previousSibling.innerText.trim();
  435. if (k == 'Q' || k == 'Q+') {
  436. t++;
  437.  
  438. }
  439. }
  440. if (t) {
  441. m.innerHTML = "Q Posts (" + t + ")";
  442. console.log(t + ' ' + window.t);
  443. if(window.t != t) {
  444. if (window.announce) clearTimeout(window.announce);
  445. var snd = new Audio(frog);
  446. snd.play();
  447.  
  448. window.announce = setTimeout(function() {
  449. var z = t;
  450. var synth = window.speechSynthesis;
  451.  
  452.  
  453. var n = document.getElementsByClassName('subject')[0];
  454. if(! n) {
  455. window.t = z;
  456. return;
  457.  
  458. }
  459. console.log(n);
  460. var num = get_bread_number(n.innerHTML);
  461.  
  462. if (chatty && synth && typeof window.breadno != 'undefined' && num ) {
  463. var utterance1 = new SpeechSynthesisUtterance("Q has posted in thread " + num);
  464. synth.speak(utterance1);
  465. }
  466. window.announce = 0;
  467. m.animate([
  468. { color: 'red' },
  469. { color: 'white' },
  470. { color: 'blue' }
  471. ], {
  472. duration: 500,
  473. iterations: 17
  474. });
  475. window.t = z;
  476. }, 3000);
  477. }
  478.  
  479. }
  480. /*
  481. if ((t != window.t) && t) {
  482. m.animate([
  483. { color: 'red' },
  484. { color: 'white' },
  485. { color: 'blue' }
  486. ], {
  487. duration: 500,
  488. iterations: 17
  489. });
  490. window.t = t;
  491. }*/
  492. var list = _$('name');
  493. for(var i = 0; i < list.length; i++) {
  494. r = list[i].innerText.trim();
  495. k = list[i].nextSibling;
  496.  
  497. if (k && k.className!='trip') {
  498. if (r == 'Q' || r == 'Q+') {
  499. list[i].innerHTML = r
  500. + " <span style='color:red'>[FAKE]</span>";
  501. }
  502. }
  503. }
  504.  
  505. }
  506.  
  507. function find_recent_bread(board) {
  508. var now = ~~((new Date).getTime() / 1000);
  509. var thread;
  510. for(var i = 0; i < board.length; i++) {
  511. for(var j = 0; j < board[i].threads.length; j++) {
  512. thread = board[i].threads[j];
  513. // only show threads modified within the last 2 hours
  514.  
  515. if (now - thread.last_modified < 7200) {
  516. make_toast('/qresearch/res/'+thread.no + '.json',
  517. thread.last_modified);
  518. }
  519. }
  520. }
  521.  
  522. }
  523.  
  524. // Post controls is loaded and we're already in a thread
  525. // append the controls at the top, but only once.
  526. var toast_init = function() {
  527. container = (_n('postcontrols'))[0];
  528. var dythreads = _i('dythreads');
  529.  
  530. if (! dythreads && typeof container != 'undefined') {
  531.  
  532. var bl = _$('boardlist')[0];
  533.  
  534.  
  535. var box = _c('DIV', 'notify');
  536. var bar = _c('DIV', 'dythreads');
  537. var label = _c('LABEL', 'search_input');
  538. var text = _c(label, 'Search:');
  539. var search = _c('INPUT', 'search_input');
  540.  
  541. container.appendChild(bar);
  542. bar.appendChild(label);
  543. bar.appendChild(search);
  544. bar.appendChild(box);
  545.  
  546. css(bar,{
  547. top : bl.clientHeight + 'px',
  548. width : 'calc(100% - 8px)',
  549. height : '16px',
  550. margin : '0 0 0 -16px',
  551. zIndex : '100',
  552. display : 'block',
  553. padding : '0 8px 0 16px',
  554. position : 'fixed',
  555. textAlign : 'left',
  556. background : '#eef2ff url(/stylesheets/img/fade-blue.png)'
  557. + ' repeat-x 50% 0%',
  558. borderBottom : '1px solid #b0b0b0'
  559. });
  560.  
  561. css(search,{
  562. font : 'normal normal bold 8px/13px "Courier New", '
  563. + 'Courier, Monospace',
  564. float :'left',
  565. height :'9px',
  566. border :'none',
  567. marginTop :'2px'
  568. });
  569.  
  570. css(label,{
  571. font : 'normal normal bold 8px/15px "Courier New", '
  572. + 'Courier, Monospace',
  573. float :'left',
  574. height : '13px',
  575. });
  576.  
  577. css(box,{
  578. font : 'normal normal bold 8px/13px "Courier New", '
  579. + 'Courier, Monospace',
  580. color : 'red',
  581. width : '105px',
  582. float : 'left',
  583. height : '15px',
  584. margin : '2px 0 0 5px'
  585. });
  586.  
  587.  
  588.  
  589. setInterval("refresh();", 5000);
  590. search.onkeyup =
  591. search.oninput =
  592. search.onchange =
  593. search.onkeydown = function(e) {
  594. var c;
  595. e = e || event;
  596. c = (e.keyCode || e.which || e.charCode || 0)
  597. if (c == 13) e.stopPropagation();
  598. if (window.to) clearTimeout(window.to);
  599. window.to = setTimeout(function() {
  600. filter_by_id();
  601. }, 1000);
  602.  
  603. return c !== 13;
  604. };
  605. var auto = _i('auto_update_status');
  606. if (auto) {
  607.  
  608. auto.setAttribute('checked',true);
  609. //auto.setPropertyuchecked = true;
  610. }
  611. refresh();
  612. make_toast('#',0);
  613. }
  614. }
  615. $(document).ready(toast_init);
  616. //IMAGE BLACKLIST CODING
  617. var imageBlacklist = [] ;
  618. function loadImageBlacklist() { JSON.parse(localStorage.imageBlacklist || "[]").forEach(addToImageBlaclist); }
  619. function saveImageBlacklist() { localStorage.imageBlacklist = JSON.stringify(imageBlacklist); }
  620. function addToImageBlaclist(md5) { if (md5 && -1 === imageBlacklist.indexOf(md5)) imageBlacklist.push(md5); }
  621. function blacklistPostImages(post) { $(post).find('img.post-image').each(function (i, el) { var md5 = el.getAttribute('data-md5'); addToImageBlaclist(md5); el.remove(); }); }
  622. function removeBlacklistedImages() { var removed = 0; $('img.post-image').each(function (i, el) { if (-1 !== imageBlacklist.indexOf(el.getAttribute('data-md5'))) { el.remove(); removed += 1; } }); return removed; }
  623. function onNopeClicked(event) { event.preventDefault(); event.stopPropagation(); loadImageBlacklist(); var post = $(event.target).closest('.post'); blacklistPostImages(post); removeBlacklistedImages(); saveImageBlacklist(); }
  624. 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>"); } }) }
  625.  
  626. setInterval(function () { loadImageBlacklist(); removeBlacklistedImages(); addNopeButtons(); }, 500);
Add Comment
Please, Sign In to add comment