Guest User

Untitled

a guest
Sep 8th, 2018
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.95 KB | None | 0 0
  1. //================================================================
  2. //
  3. // Toastmaster 2.3.0
  4. // Finds the bread so you don't have to.
  5. //
  6. // Always look through the code to find shifty stuff.
  7. //
  8. //
  9. //================================================================
  10. //2345678901234567890123456789012345678901234567890123456789012345
  11. /* this is literally just a picture of toast */
  12.  
  13. var toast = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABsAA"
  14. + "AAbCAMAAAC6CgRnAAAARVBMVEWZMwAAAABmMwBmMzNmZjOZZgCZ"
  15. + "ZjOZZmbMZgDMZjPMZmaZmTOZmWbMmTPMmWbMmZn/mWbMzGbMzJn"
  16. + "/zGb/zJn/zMz//8zDFCa2AAAAAXRSTlMAQObYZgAAAAlwSFlzAA"
  17. + "ALEwAACxMBAJqcGAAAAAd0SU1FB+IIBAI4ECHmtE4AAAFKSURBV"
  18. + "CjPVVIBcsMwCKubQuZb0J2xu/8/dRJJt5ZzcnGEhAy+3V7R3uL2"
  19. + "FtrfffN927a7P+7tDYEDuRiZ4II/LrQ5EQwQKVAp8HZCBu6Jrpm"
  20. + "5JpiST+ytBGFBovIrB5iDX3RECCKKh+SDSoxEYaYtWVEkhkdgCl"
  21. + "uBTmIO2kHwr015m6mCqROMkMwsOcjOurwERYbcpBDrgfyBsPpDM"
  22. + "VHLiVTYifJ5sEiWKs6FoLtRPo+ijXI4aazzvGEvrHJXnAcgyi9b"
  23. + "wiyrm8mKKUCS5IJnaPFfpXrHWt27xyqsV8Fuhu5yadHDIcy+7eK"
  24. + "xWVaaqKyz15IHaWFfTjkhvTQpEp1pxmWdc+aL7D/M1F1a57l6KI"
  25. + "GwNPuCrOZ5tlVvCsU4edX6+he8E+xY5bWaA0eX6+BgBq/SwfGz/"
  26. + "2EahAbLGgd8Z/92v0JD+rjQH/ELBU8elOTZkAQAAAAASUVORK5C"
  27. + "YII=";
  28.  
  29. function _i(o) {
  30. return (o) ? document.getElementById(o) : null;
  31. }
  32. function _n(o) {
  33. return (o) ? document.getElementsByName(o) : [];
  34. }
  35. function _t(o) {
  36. return (o) ? document.getElementsByTagName(o) : [];
  37. }
  38. function _$(o) {
  39. return (o) ? document.getElementsByClassName(o): [];
  40. }
  41.  
  42. var container = (_n('postcontrols'))[0];
  43.  
  44. function _c(ob,id) {
  45. switch(ob) {
  46. case 'DIV':
  47. case 'SPAN':
  48. case 'INPUT':
  49. var ob = document.createElement(ob);
  50. ob.id = id;
  51. break;
  52. case 'LABEL':
  53. var ob = document.createElement(ob);
  54. ob.setAttribute('for', id);
  55. break;
  56. default:
  57. ob.appendChild(document.createTextNode(id));
  58. }
  59. return ob;
  60. }
  61.  
  62. function css(s, j) {
  63. for(var k in j) {
  64. s.style[k] = j[k];
  65. }
  66. }
  67.  
  68. function filter_by_id() {
  69. var id = _i('search_input').value;
  70. var list = _$('poster_id');
  71. var node;
  72. var valid;
  73. for(var i = 0; i < list.length; i++) {
  74. node = (list[i].parentNode.parentNode);
  75. valid = (-1 == node.innerText.indexOf(id));
  76. node.style.display=(valid)?'none':'inline-block';
  77. if (node.nextSibling) {
  78. node.nextSibling.style.display=(valid)?'none':'inline';
  79. }
  80. }
  81. }
  82.  
  83. function get_bread_number(text) {
  84. if ( (text.toLowerCase().indexOf('ebake') != -1)
  85. || (text.toLowerCase().indexOf('q research') != -1)) {
  86. var rx = /[^0-9]*([0-9]+)[^0-9]*/g;
  87. var arr = rx.exec(text);
  88. return arr && arr.length > 1 ? arr[1] : false;
  89. }
  90.  
  91. return false;
  92. }
  93.  
  94. function make_toast(url, time) {
  95.  
  96. var response;
  97. var x = new XMLHttpRequest();
  98. x.open('GET', url, true);
  99. x.onreadystatechange = function() {
  100. if(x.readyState === 4 && x.status == 200) {
  101. response = JSON.parse(x.responseText);
  102.  
  103. var container = _i('dythreads');
  104.  
  105. var bread = response.posts[0];
  106. var posts = response.posts.length;
  107. var txt = bread.sub;
  108.  
  109. if (typeof txt == 'undefined') {
  110. txt = bread.com;
  111. if (txt.length > 40) {
  112. txt = txt.substring(0,39) + '...';
  113. }
  114. }
  115.  
  116. var num = get_bread_number(txt);
  117. if (false == num) return;
  118. var thread = _n('thread');
  119. var colors = ((thread[0].value == bread.no)
  120. ? ((posts < 750)
  121. ? ["#04ae04", "white", "black"]
  122. : ["#ae0404", "white", "black"])
  123. : ["#fefefe", "green", "red"]);
  124.  
  125. if (thread[0].value == bread.no) {
  126. var pfi = _i('post-form-inner');
  127.  
  128. if (pfi && (posts > 750)) {
  129. css(pfi,{
  130. border :'3px solid red',
  131. padding :'3px',
  132. opacity : '0.7',
  133. background : 'url(data:image/png;base64,iVB'
  134. + 'ORw0KGgoAAAANSUhEUgAAAAQAAAAE'
  135. + 'CAYAAACp8Z5+AAAAGklEQVQIW2NkY'
  136. + 'GD4D8SMQAwGcAY2AbBKDBUAVuYCBQ'
  137. + 'Pd34sAAAAASUVORK5CYII=) repeat',
  138. borderRadius : '10px',
  139. });
  140. }
  141. }
  142.  
  143. var opts = _n('toast');
  144.  
  145. for(var i = 0; i < opts.length; i++) {
  146. if (opts[i].getAttribute('no') == bread.no) {
  147. opts[i].innerHTML = num
  148. + " <span style='font-weight:bold;color:"
  149. + colors[2]
  150. + "'>"
  151. + posts
  152. +"</span>";
  153.  
  154. opts[i].style.background = colors[0]
  155. + " url("
  156. + toast
  157. + ") 0px 0px/25px 25px no-repeat";
  158.  
  159. opts[i].style.backgroundSize = "13px";
  160.  
  161. return;
  162. }
  163.  
  164. }
  165.  
  166. var opt = _c('SPAN', "" + bread.no);
  167.  
  168. opt.setAttribute('no',bread.no);
  169.  
  170. opt.addEventListener('mouseout',function() {
  171. css(opt,{
  172. cursor : 'pointer',
  173. filter : 'brightness(100%)'
  174. })
  175. });
  176.  
  177. opt.addEventListener('mouseover',function() {
  178. css(opt,{
  179. cursor : 'auto',
  180. filter : 'brightness(80%)'
  181. })
  182. });
  183.  
  184. css(opt,{
  185. font : 'normal normal bold 8px/15px '
  186. + '"Courier New", Courier, Monospace',
  187. float : 'right',
  188. color : colors[1],
  189. width : '59px',
  190. height : '13px',
  191. margin : '1px',
  192. border : '1px solid #b0b0b0',
  193. display : 'inline-block',
  194. filter : 'brightness(100%)',
  195. textAlign : 'left',
  196. textIndent : '18px',
  197. background : colors[0] + ' url(' + toast
  198. + ') 0px 0px/25px 25px no-repeat',
  199.  
  200. borderRadius : '3px',
  201. verticalAlign : 'top',
  202. backgroundSize : '13px'
  203. });
  204.  
  205. opt.innerHTML = num
  206. + " <span style='font-weight:bold;color:"
  207. + colors[2]
  208. + ";'>"
  209. + posts
  210. + "</span>";
  211.  
  212. opt.id = "" + bread.no;
  213.  
  214. container.appendChild(opt);
  215.  
  216. opt.setAttribute('name','toast');
  217.  
  218. opt.onclick = function () {
  219. var no = bread.no;
  220. if(typeof url != 'undefined') {
  221. window.location.href =
  222. '/qresearch/res/' + no + '.html';
  223. }
  224. };
  225.  
  226. opt.setAttribute('old',false);
  227. }
  228. };
  229. x.send();
  230.  
  231. }
  232.  
  233. // every 60 seconds we reload from threads.json
  234.  
  235. function refresh() {
  236. // prune expired breads and append new ones.
  237. var opts = _n('toast');
  238.  
  239. for(var i = 0; i < opts.length; i++) {
  240. if (opts[i].getAttribute('old') == true) {
  241. container.removeChild(opts[i]);
  242. console.log('removed option ' + i)
  243. }
  244. else {
  245. opts[i].setAttribute('old',true);
  246. }
  247. }
  248.  
  249. var x = new XMLHttpRequest();
  250. x.open('GET', "/qresearch/threads.json", true);
  251. x.onreadystatechange = function() {
  252. if(x.readyState === 4 && x.status == 200) {
  253. var response = JSON.parse(x.responseText);
  254. find_recent_bread(response);
  255. }
  256. };
  257. x.send();
  258. trips();
  259.  
  260. }
  261. // Count instances of Q with trips, mark untripped Q's as fakes
  262. function trips() {
  263. var m = _i('notify');
  264. var t = 0;
  265. var k, r;
  266. var list = _$('trip');
  267. for(var i = 0; i < list.length; i++) {
  268. r = list[i].innerText.trim();
  269. if (list[i].parentNode.parentNode.className !='intro') continue;
  270. if (! r.length || r == 'FAKE') {
  271. continue;
  272. }
  273. k = list[i].previousSibling.innerText.trim();
  274. if (k == 'Q' || k == 'Q+') {
  275. t++;
  276.  
  277. }
  278. }
  279. if (t) {
  280. m.innerHTML = "Q Posts (" + t + ")";
  281. }
  282. if ((t != window.t) && t) {
  283. m.animate([
  284. { color: 'red' },
  285. { color: 'white' },
  286. { color: 'blue' }
  287. ], {
  288. duration: 500,
  289. iterations: 17
  290. });
  291. window.t = t;
  292. }
  293. var list = _$('name');
  294. for(var i = 0; i < list.length; i++) {
  295. r = list[i].innerText.trim();
  296. k = list[i].nextSibling;
  297.  
  298. if (k.className!='trip') {
  299. if (r == 'Q' || r == 'Q+') {
  300. list[i].innerHTML = r
  301. + " <span style='color:red'>[FAKE]</span>";
  302. }
  303. }
  304. }
  305.  
  306. }
  307.  
  308. function find_recent_bread(board) {
  309. var now = ~~((new Date).getTime() / 1000);
  310. var thread;
  311. for(var i = 0; i < board.length; i++) {
  312. for(var j = 0; j < board[i].threads.length; j++) {
  313. thread = board[i].threads[j];
  314. // only show threads modified within the last 2 hours
  315.  
  316. if (now - thread.last_modified < 7200) {
  317. make_toast('/qresearch/res/'+thread.no + '.json',
  318. thread.last_modified);
  319. }
  320. }
  321. }
  322. }
  323.  
  324. // Post controls is loaded and we're already in a thread
  325. // append the controls at the top, but only once.
  326. var dythreads = _i('dythreads');
  327.  
  328. if (container && ! dythreads) {
  329.  
  330. var box = _c('DIV', 'notify');
  331. var bar = _c('DIV', 'dythreads');
  332. var label = _c('LABEL', 'search_input');
  333. var text = _c(label, 'Search:');
  334. var search = _c('INPUT', 'search_input');
  335.  
  336. container.appendChild(bar);
  337. bar.appendChild(label);
  338. bar.appendChild(search);
  339. bar.appendChild(box);
  340.  
  341. css(bar,{
  342. top : '15px',
  343. width : 'calc(100% - 8px)',
  344. height : '16px',
  345. margin : '0 0 0 -16px',
  346. zIndex : '100',
  347. display : 'block',
  348. padding : '0 8px 0 16px',
  349. position : 'fixed',
  350. textAlign : 'left',
  351. background : '#eef2ff url(/stylesheets/img/fade-blue.png)'
  352. + ' repeat-x 50% 0%',
  353. borderBottom : '1px solid #b0b0b0'
  354. });
  355.  
  356. css(search,{
  357. font : 'normal normal bold 8px/13px "Courier New", '
  358. + 'Courier, Monospace',
  359. float :'left',
  360. height :'9px',
  361. border :'none',
  362. marginTop :'2px'
  363. });
  364.  
  365. css(label,{
  366. font : 'normal normal bold 8px/15px "Courier New", '
  367. + 'Courier, Monospace',
  368. float :'left',
  369. height : '13px',
  370. });
  371.  
  372. css(box,{
  373. font : 'normal normal bold 8px/13px "Courier New", '
  374. + 'Courier, Monospace',
  375. color : 'red',
  376. width : '105px',
  377. float : 'left',
  378. height : '15px',
  379. margin : '2px 0 0 5px'
  380. });
  381.  
  382.  
  383. setInterval("refresh();", 5000);
  384.  
  385. search.onkeyup =
  386. search.oninput =
  387. search.onchange =
  388. search.onkeydown = function(e) {
  389. var c;
  390. e = e || event;
  391. c = (e.keyCode || e.which || e.charCode || 0)
  392. if (c == 13) e.stopPropagation();
  393. if (window.to) clearTimeout(window.to);
  394. window.to = setTimeout(function() {
  395. filter_by_id();
  396. }, 1000);
  397.  
  398. return c !== 13;
  399. };
  400.  
  401. refresh();
  402. }
Advertisement
Add Comment
Please, Sign In to add comment