Advertisement
Guest User

Untitled

a guest
Sep 10th, 2018
434
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.34 KB | None | 0 0
  1. //================================================================
  2. //
  3. // Toastmaster 2.4.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. window.colored = 0;
  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.  
  120. var hrefs = _t('A');
  121. for(var i = window.colored; i < hrefs.length; i++) {
  122.  
  123. if (-1 == hrefs[i].href.indexOf("res/" + thread[0].value+".html") &&
  124. -1 != hrefs[i].href.indexOf("qresearch")) {
  125. hrefs[i].style.color='#0077aa';
  126. window.colored = i; // don't color it twice.
  127. }
  128. }
  129.  
  130. var colors = ((thread[0].value == bread.no)
  131. ? ((posts < 750)
  132. ? ["#04ae04", "white", "black"]
  133. : ["#ae0404", "white", "black"])
  134. : ["#fefefe", "green", "red"]);
  135.  
  136. if (thread[0].value == bread.no) {
  137. var pfi = _i('post-form-inner');
  138.  
  139. if (pfi && (posts > 750)) {
  140. css(pfi,{
  141. border :'3px solid red',
  142. padding :'3px',
  143. opacity : '0.7',
  144. background : 'url(data:image/png;base64,iVB'
  145. + 'ORw0KGgoAAAANSUhEUgAAAAQAAAAE'
  146. + 'CAYAAACp8Z5+AAAAGklEQVQIW2NkY'
  147. + 'GD4D8SMQAwGcAY2AbBKDBUAVuYCBQ'
  148. + 'Pd34sAAAAASUVORK5CYII=) repeat',
  149. borderRadius : '10px',
  150. });
  151. }
  152. }
  153.  
  154. var opts = _n('toast');
  155.  
  156. for(var i = 0; i < opts.length; i++) {
  157. if (opts[i].getAttribute('no') == bread.no) {
  158. opts[i].innerHTML = num
  159. + " <span style='font-weight:bold;color:"
  160. + colors[2]
  161. + "'>"
  162. + posts
  163. +"</span>";
  164.  
  165. opts[i].style.background = colors[0]
  166. + " url("
  167. + toast
  168. + ") 0px 0px/25px 25px no-repeat";
  169.  
  170. opts[i].style.backgroundSize = "13px";
  171.  
  172. return;
  173. }
  174.  
  175. }
  176.  
  177. var opt = _c('SPAN', "" + bread.no);
  178.  
  179. opt.setAttribute('no',bread.no);
  180.  
  181. opt.addEventListener('mouseout',function() {
  182. css(opt,{
  183. cursor : 'pointer',
  184. filter : 'brightness(100%)'
  185. })
  186. });
  187.  
  188. opt.addEventListener('mouseover',function() {
  189. css(opt,{
  190. cursor : 'auto',
  191. filter : 'brightness(80%)'
  192. })
  193. });
  194.  
  195. css(opt,{
  196. font : 'normal normal bold 8px/15px '
  197. + '"Courier New", Courier, Monospace',
  198. float : 'right',
  199. color : colors[1],
  200. width : '59px',
  201. height : '13px',
  202. margin : '1px',
  203. border : '1px solid #b0b0b0',
  204. display : 'inline-block',
  205. filter : 'brightness(100%)',
  206. textAlign : 'left',
  207. textIndent : '18px',
  208. background : colors[0] + ' url(' + toast
  209. + ') 0px 0px/25px 25px no-repeat',
  210.  
  211. borderRadius : '3px',
  212. verticalAlign : 'top',
  213. backgroundSize : '13px'
  214. });
  215.  
  216. opt.innerHTML = num
  217. + " <span style='font-weight:bold;color:"
  218. + colors[2]
  219. + ";'>"
  220. + posts
  221. + "</span>";
  222.  
  223. opt.id = "" + bread.no;
  224.  
  225. container.appendChild(opt);
  226.  
  227. opt.setAttribute('name','toast');
  228.  
  229. opt.onclick = function () {
  230. var no = bread.no;
  231. if(typeof url != 'undefined') {
  232. window.location.href =
  233. '/qresearch/res/' + no + '.html';
  234. }
  235. };
  236.  
  237. opt.setAttribute('old',false);
  238. }
  239. };
  240. x.send();
  241.  
  242. }
  243.  
  244. // every 60 seconds we reload from threads.json
  245.  
  246. function refresh() {
  247. // prune expired breads and append new ones.
  248. var opts = _n('toast');
  249.  
  250. for(var i = 0; i < opts.length; i++) {
  251. if (opts[i].getAttribute('old') == true) {
  252. container.removeChild(opts[i]);
  253.  
  254. }
  255. else {
  256. opts[i].setAttribute('old',true);
  257. }
  258. }
  259.  
  260. var x = new XMLHttpRequest();
  261. x.open('GET', "/qresearch/threads.json", true);
  262. x.onreadystatechange = function() {
  263. if(x.readyState === 4 && x.status == 200) {
  264. var response = JSON.parse(x.responseText);
  265. find_recent_bread(response);
  266. }
  267. };
  268. x.send();
  269. trips();
  270.  
  271. }
  272. // Count instances of Q with trips, mark untripped Q's as fakes
  273. function trips() {
  274. var m = _i('notify');
  275. var t = 0;
  276. var k, r;
  277. var list = _$('trip');
  278. for(var i = 0; i < list.length; i++) {
  279. r = list[i].innerText.trim();
  280. if (list[i].parentNode.parentNode.className !='intro') continue;
  281. if (! r.length || r == 'FAKE') {
  282. continue;
  283. }
  284. k = list[i].previousSibling.innerText.trim();
  285. if (k == 'Q' || k == 'Q+') {
  286. t++;
  287.  
  288. }
  289. }
  290. if (t) {
  291. m.innerHTML = "Q Posts (" + t + ")";
  292. }
  293. if ((t != window.t) && t) {
  294. m.animate([
  295. { color: 'red' },
  296. { color: 'white' },
  297. { color: 'blue' }
  298. ], {
  299. duration: 500,
  300. iterations: 17
  301. });
  302. window.t = t;
  303. }
  304. var list = _$('name');
  305. for(var i = 0; i < list.length; i++) {
  306. r = list[i].innerText.trim();
  307. k = list[i].nextSibling;
  308.  
  309. if (k && k.className!='trip') {
  310. if (r == 'Q' || r == 'Q+') {
  311. list[i].innerHTML = r
  312. + " <span style='color:red'>[FAKE]</span>";
  313. }
  314. }
  315. }
  316.  
  317. }
  318.  
  319. function find_recent_bread(board) {
  320. var now = ~~((new Date).getTime() / 1000);
  321. var thread;
  322. for(var i = 0; i < board.length; i++) {
  323. for(var j = 0; j < board[i].threads.length; j++) {
  324. thread = board[i].threads[j];
  325. // only show threads modified within the last 2 hours
  326.  
  327. if (now - thread.last_modified < 7200) {
  328. make_toast('/qresearch/res/'+thread.no + '.json',
  329. thread.last_modified);
  330. }
  331. }
  332. }
  333. }
  334.  
  335. // Post controls is loaded and we're already in a thread
  336. // append the controls at the top, but only once.
  337. var dythreads = _i('dythreads');
  338.  
  339. if (container && ! dythreads) {
  340.  
  341. var box = _c('DIV', 'notify');
  342. var bar = _c('DIV', 'dythreads');
  343. var label = _c('LABEL', 'search_input');
  344. var text = _c(label, 'Search:');
  345. var search = _c('INPUT', 'search_input');
  346.  
  347. container.appendChild(bar);
  348. bar.appendChild(label);
  349. bar.appendChild(search);
  350. bar.appendChild(box);
  351.  
  352. css(bar,{
  353. top : '15px',
  354. width : 'calc(100% - 8px)',
  355. height : '16px',
  356. margin : '0 0 0 -16px',
  357. zIndex : '100',
  358. display : 'block',
  359. padding : '0 8px 0 16px',
  360. position : 'fixed',
  361. textAlign : 'left',
  362. background : '#eef2ff url(/stylesheets/img/fade-blue.png)'
  363. + ' repeat-x 50% 0%',
  364. borderBottom : '1px solid #b0b0b0'
  365. });
  366.  
  367. css(search,{
  368. font : 'normal normal bold 8px/13px "Courier New", '
  369. + 'Courier, Monospace',
  370. float :'left',
  371. height :'9px',
  372. border :'none',
  373. marginTop :'2px'
  374. });
  375.  
  376. css(label,{
  377. font : 'normal normal bold 8px/15px "Courier New", '
  378. + 'Courier, Monospace',
  379. float :'left',
  380. height : '13px',
  381. });
  382.  
  383. css(box,{
  384. font : 'normal normal bold 8px/13px "Courier New", '
  385. + 'Courier, Monospace',
  386. color : 'red',
  387. width : '105px',
  388. float : 'left',
  389. height : '15px',
  390. margin : '2px 0 0 5px'
  391. });
  392.  
  393.  
  394. setInterval("refresh();", 5000);
  395. search.onkeyup =
  396. search.oninput =
  397. search.onchange =
  398. search.onkeydown = function(e) {
  399. var c;
  400. e = e || event;
  401. c = (e.keyCode || e.which || e.charCode || 0)
  402. if (c == 13) e.stopPropagation();
  403. if (window.to) clearTimeout(window.to);
  404. window.to = setTimeout(function() {
  405. filter_by_id();
  406. }, 1000);
  407.  
  408. return c !== 13;
  409. };
  410.  
  411. refresh();
  412. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement