Advertisement
Guest User

Untitled

a guest
Aug 19th, 2022
549
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.93 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Reports - Hotpocket Helper
  3. // @version 6.4
  4. // @description My report queue is augmented
  5. // @author (cyg && fsn) == bffs 5ever
  6. // @match https://reports.4chan.org/*
  7. // @exclude https://reports.4chan.org/?action*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. var CFRQ = {
  15. slugLevels: [
  16. {count: 9, color: "#CCFFCC"},
  17. {count: 10, color: "#6FFF6F"},
  18. {count: 25, color: "#FAFF3D"},
  19. {count: 50, color: "#FE8F3D"},
  20. {count: 75, color: "#FF6F6F"},
  21. {count: 100, color: "#FF0000"}
  22. ],
  23. //don't touch anything below this line
  24. firstRun: true,
  25. buttons: {
  26. "Threads":"cfrq-threads",
  27. "OP":"cfrq-opsfilt",
  28. "Reply":"cfrq-replyfilt",
  29. "Sync":"cfrq-forcesync"
  30. }
  31. };
  32.  
  33. CFRQ.refresh = function() {
  34. CFRQ.stats = {};
  35. CFRQ.threads = {};
  36. CFRQ.xhr = {};
  37. CFRQ.parsePage();
  38. //$.on(document, "keydown", CFRQ.onKeydown);
  39. //CFRQ.clearTooltips();
  40. window.RQ.settingsList.autoSortThreads = ["Sort by thread on page load", false];
  41. window.RQ.settingsList.autoScrollNav = ["Pin toolbar to top of page", true];
  42. if (window.RQ.board) CFRQ.fetchThreadlist(window.RQ.board);
  43. };
  44.  
  45. //Loop through each report, add buttons, link checkboxes, gather stats for thread sorting
  46. CFRQ.parsePage = function() {
  47. var report, reports = $.qsa("article");
  48. for (var b in CFRQ.buttons) { //Reset all button states
  49. if ($.hasClass($.id(CFRQ.buttons[b]), "disabled")) {
  50. $.removeClass($.id(CFRQ.buttons[b]), "disabled");
  51. }
  52. }
  53.  
  54. for (var i = 0; (report = reports[i]); ++i) {
  55. CFRQ.parseReport(report);
  56. }
  57.  
  58. CFRQ.parseSlugs();
  59.  
  60. CFRQ.sortThreadsByReply();
  61. CFRQ.firstRun = false;
  62.  
  63. if (window.RQ.settings.autoSortThreads) {
  64. CFRQ.filterThreads();
  65. }
  66. };
  67.  
  68. CFRQ.parseSlugs = function() {
  69. CFRQ.boardList = [];
  70. var slug, slugs = $.cls("board-slug");
  71. for (var i = 0; (slug = slugs[i]); ++i) {
  72. CFRQ.boardList.push(slug.textContent);
  73. CFRQ.stats[slug.textContent] = slug.getAttribute("data-tip");
  74. slug.id = "board-slug-" + slug.innerHTML;
  75. CFRQ.updateSlug(slug);
  76. }
  77. };
  78.  
  79. CFRQ.parseReport = function(report) {
  80. if (report.getAttribute("cfrq-parent")) { return; }
  81. var id = report.id.split("-")[2];
  82. var board = report.id.split("-")[1];
  83. var resto_no = report.getAttribute("data-tid") || id;
  84. var resto = board + "-" + (resto_no);
  85. var button = $.el("span");
  86. button.textContent = (report.hasAttribute("data-tid") ? "OP" : "I");
  87. //button.setAttribute("data-tip", "Loading thread stats...");
  88. button.className = "button";
  89. button.setAttribute('data-board', board);
  90. button.setAttribute('data-resto', (report.getAttribute('data-tid') || id));
  91. var controls = $.qs(".report-controls", report);
  92. controls.appendChild(button); //Add info button to each report control pane
  93. $.on(button, "mouseover", CFRQ.threadStatsMouseover);
  94. $.on(button, "mouseover", function() {
  95. try {
  96. $.id("data-tip").parentNode.removeChild($.id("tooltip"));
  97. } catch(e) {
  98. //shut up
  99. }
  100. });
  101. if (report.hasAttribute("data-tid")) {
  102. $.on(button, "click", CFRQ.togglePreviewOP);
  103. }
  104. report.setAttribute("cfrq-parent", resto);
  105.  
  106. /* If it's an illegal report, add 1000 reports
  107. for this thread so it always appears at the top of thread sorting
  108. */
  109. if (CFRQ.threads[resto]) {
  110. CFRQ.threads[resto] += ($.hasClass(report, "report-cat-prio") ? 1000 : 1);
  111. } else {
  112. CFRQ.threads[resto] = ($.hasClass(report, "report-cat-prio") ? 1000 : 1);
  113. }
  114.  
  115. CFRQ.parseQuotelinks(report, resto_no, board);
  116. };
  117.  
  118. CFRQ.parseQuotelinks = function(report, resto, board) {
  119. //Post links
  120. var i, qlink, tmp, qlinks = $.cls("quotelink", report), tmptxt = "";
  121. for (i = 0; (qlink = qlinks[i]); ++i) {
  122. qlink.style = "pointer-events:all;cursor:pointer;";
  123. var href = qlink.getAttribute("href") //messes up RQ if we leave the href
  124. qlink.target = "_blank";
  125. if (!href) return;
  126.  
  127. if (qlink.textContent.match(/^>>>/)) {
  128. board = qlink.textContent.split("/")[1];
  129. tmp = href.split("/");
  130. if (tmp.length < 6) {
  131. return;
  132. } else {
  133. resto = tmp[5].split("#")[0];
  134. tmptxt = " (Cross-board)";;
  135. }
  136. } else if (href.includes("thread")) {
  137. resto = href.split("/")[3].split("#")[0];
  138. tmptxt = " (Cross-thread)";
  139. }
  140. qlink.removeAttribute("href");
  141.  
  142. var linkParts = href.split("/");
  143. var targetPost = linkParts[linkParts.length - 1].split("#p")[1];
  144.  
  145. qlink.setAttribute("data-cmd", "cfrq-quotelink");
  146.  
  147. qlink.setAttribute("data-board", board);
  148. qlink.setAttribute("data-resto", resto);
  149. qlink.setAttribute("data-target", targetPost);
  150.  
  151. qlink.textContent += tmptxt;
  152. }
  153. qlinks = $.cls("deadlink", report);
  154. if (qlinks.length != 0) {
  155. for (i = 0; (qlink = qlinks[i]); ++i) {
  156. qlink.style = "color:red;";
  157. qlink.setAttribute("href", "#p404");
  158. }
  159. }
  160. };
  161.  
  162. CFRQ.togglePreviewOP = function(el) {
  163. var btn = el.target;
  164. var board = btn.getAttribute('data-board');
  165. var resto = btn.getAttribute('data-resto');
  166. if (board == "null") {
  167. board = btn.parentNode.parentNode.getAttribute('data-board');
  168. }
  169.  
  170. var targ = "cfrq-preview-" + board + "-" + (btn.getAttribute("data-target") || resto);
  171. if ($.id(targ)) {
  172. while($.cls(btn.parentNode.parentNode.id.split("-")[2])[0]) {
  173. $.cls(btn.parentNode.parentNode.id.split("-")[2])[0].parentNode.removeChild($.cls(btn.parentNode.parentNode.id.split("-")[2])[0]);
  174. }
  175. $.removeClass(btn, "disabled");
  176. $.removeClass(btn, "focused");
  177. } else {
  178. CFRQ.previewOP(el);
  179. }
  180. };
  181.  
  182. CFRQ.previewOP = function(el) {
  183. var btn = el.target;
  184. var board = btn.getAttribute('data-board');
  185. var resto = btn.getAttribute('data-resto');
  186.  
  187. if (board == "null") {
  188. board = btn.parentNode.parentNode.getAttribute('data-board');
  189. }
  190.  
  191. CFRQ.viewThread = true;
  192. window.RQ.showContext(board, resto, resto);
  193. };
  194.  
  195. CFRQ.fetchThreadlist = function(board) {
  196. if (CFRQ.xhr[board]) return;
  197.  
  198. $.xhr("GET", `https://a.4cdn.org/${board}/threads.json`, {
  199. onreadystatechange: function() {
  200. if (this.status == 200 && this.readyState == 4) {
  201. CFRQ.xhr[board] = JSON.parse(this.responseText);
  202. }
  203. },
  204. onerror: function() {
  205. window.RQ.notify("Connection error");
  206. }
  207. });
  208. };
  209.  
  210. CFRQ.fetchBoardList = function() {
  211. if ($.getItem("cfrq-boardlist")) { //Have it already breh
  212. CFRQ.boardlist = JSON.parse($.getItem("cfrq-boardlist"));
  213. return;
  214. }
  215. $.xhr("GET", `https://a.4cdn.org/boards.json`, {
  216. onreadystatechange: function() {
  217. if (this.status == 200 && this.readyState == 4) {
  218. CFRQ.boardlist = JSON.parse(this.responseText);
  219. $.setItem("cfrq-boardlist", this.responseText);
  220. }
  221. },
  222. onerror: function() {
  223. window.RQ.notify("Connection error");
  224. }
  225. });
  226. };
  227.  
  228. CFRQ.threadStatsMouseover = function(el) {
  229. CFRQ.clearTooltips();
  230. var btn = el.target;
  231. var board = btn.getAttribute('data-board');
  232. var resto = btn.getAttribute('data-resto');
  233. CFRQ.fetchThreadlist(board);
  234.  
  235. var last = btn.getAttribute("data-last-retrieved");
  236. if (last && (last > $.now() - 10)) return; //Stop if we last checked this thread's stats less than n seconds ago
  237. btn.setAttribute('data-last-retrieved', $.now());
  238. var oc = btn.textContent;
  239.  
  240. var loop = setInterval(function() {
  241. //if (btn.textContent.length == oc) {
  242. // btn.textContent = "....";
  243. //}
  244. if (/\.\.\./.test(btn.textContent)) {
  245. btn.textContent = oc;
  246. }
  247. }, 10);
  248.  
  249. $.xhr("GET", `https://a.4cdn.org/${board}/thread/${resto}.json`, {
  250. onreadystatechange: function() {
  251. if (this.status == 200 && this.readyState == 4) {
  252. CFRQ.xhr[board + "-" + resto] = JSON.parse(this.responseText);
  253. CFRQ.updateThreadStats(btn);
  254. clearInterval(loop);
  255. btn.textContent = oc;
  256. }
  257. },
  258. onerror: function() {
  259. window.RQ.notify("That post doesn't exist anymore.");
  260. clearInterval(loop);
  261. btn.textContent = "E";
  262. $.addClass(btn, "disabled");
  263. $.addClass(btn.parentNode.parentNode, "disabled");
  264. $.off(btn, "mouseover", CFRQ.threadStatsMouseover);
  265. }
  266. });
  267. };
  268.  
  269. CFRQ.updateThreadStats = function(btn) {
  270. var article = btn.parentNode.parentNode; //tree to the <article> containing the report
  271. var board = article.getAttribute('data-board');
  272. var id = article.id.split("-")[2];
  273. var resto = article.getAttribute('data-tid') || id;
  274. var posts = CFRQ.xhr[board + "-" + resto].posts;
  275. var op = CFRQ.xhr[board + "-" + resto].posts[0];
  276.  
  277. var b, maxreps, maximgs;
  278. for (var k = 0; (b = CFRQ.boardlist.boards[k]); ++k) {
  279. if (board == b.board) {
  280. maxreps = b.bump_limit;
  281. maximgs = b.image_limit;
  282. }
  283. }
  284.  
  285. var replies = (op.replies >= 1 ? `${op.replies} of ${maxreps} replies` : `No replies`);
  286. var images = (op.images >= 1 ? `${op.images} of ${maximgs} images` : `No images`);
  287. var opAge = $.ago(op.time) + " old";
  288. var lastReply = "Last reply: " + $.ago(posts[posts.length -1].time) + " ago";
  289. var info = `${replies} | ${images} | ${opAge} | ${lastReply}`;
  290.  
  291. if (CFRQ.xhr[board] && !op.archived) { //ignore page if the xhr hasn't finished
  292. var xpage, thread, foundpage;
  293. for (var i = 0; (xpage = CFRQ.xhr[board][i]); ++i) {
  294. for (var j = 0; (thread = xpage.threads[j]); ++j) {
  295. if (thread.no == resto) foundpage = xpage.page;
  296. }
  297. }
  298. info += ` | Page: ${foundpage}`;
  299. }
  300.  
  301. window.Tip.show(btn, info);
  302. //btn.setAttribute('title', info);
  303. };
  304.  
  305. //Update a single slug based on the stats in CFBR.stats, provided a board
  306. CFRQ.updateSlug = function(slug) {
  307. var level, board = slug.id.split("board-slug-")[1];
  308. var count = CFRQ.stats[board];
  309.  
  310. if (!count) {
  311. slug.style.color = "#777";
  312. return;
  313. }
  314.  
  315. //if (RQ.board != null && RQ.board != board) return;
  316.  
  317. slug.style = {
  318. fontWeight: "", fontStyle: "", color: ""
  319. };
  320.  
  321. if (count < 10) {
  322. slug.style.color = CFRQ.slugLevels[0].color;
  323. } else if (count < 25) {
  324. slug.style.color = CFRQ.slugLevels[1].color;
  325. } else if (count < 50) {
  326. slug.style.color = CFRQ.slugLevels[2].color;
  327. } else if (count < 75) {
  328. slug.style.color = CFRQ.slugLevels[3].color;
  329. } else if (count < 100) {
  330. slug.style.color = CFRQ.slugLevels[4].color;
  331. } else {
  332. slug.style.color = CFRQ.slugLevels[5].color;
  333. }
  334. };
  335.  
  336. CFRQ.incrementStats = function(board, amount) {
  337. return (CFRQ.stats[board] ? CFRQ.stats[board] += amount : CFRQ.stats[board] = amount);
  338. };
  339.  
  340. CFRQ.decrementStats = function(board, amount) {
  341. return (CFRQ.stats[board] && CFRQ.stats[board] >= 1 ? CFRQ.stats[board] += amount : null);
  342. };
  343.  
  344. //Add filter buttons to the toolbar at the top /* delete if added natively */
  345. CFRQ.addFilters = function() {
  346. var btntxt,
  347. buttoncbks = {"OP": CFRQ.filterReport, "Reply": CFRQ.filterReport, "Threads": CFRQ.filterThreads, "Sync":window.RQ.triggerSync},
  348. buttontips = {"OP": "Show OPs only", "Reply": "Show Replies only", "Threads": "Group all by thread", "Sync":"Check for dead reports without refreshing the page"};
  349. for (btntxt in CFRQ.buttons) {
  350. var el = $.el("span");
  351. el.className = "button button-light left";
  352. el.innerHTML = btntxt;
  353. el.id = CFRQ.buttons[btntxt];
  354. el.setAttribute("data-tip", buttontips[btntxt]);
  355. $.id('refresh-btn').parentNode.insertBefore(el, $.id('refresh-btn').nextSibling);
  356. $.on($.id(CFRQ.buttons[btntxt]), "click", buttoncbks[btntxt]);
  357. }
  358. };
  359.  
  360. CFRQ.filterReport = function(el) {
  361. var btn = el.target;
  362. CFRQ.resetFilter();
  363. if ($.hasClass(btn, "disabled")) {
  364. $.removeClass(btn, "disabled");
  365. return;
  366. }
  367. var report, reports = $.cls("report"), showRepliesOnly = (btn.id == "cfrq-replyfilt");
  368. for (var i = 0; (report = reports[i]); ++i) {
  369. if (showRepliesOnly && !report.hasAttribute("data-tid")) {
  370. $.addClass(report, "hidden-i");
  371. } else if (!showRepliesOnly && report.hasAttribute("data-tid")) {
  372. $.addClass(report, "hidden-i");
  373. }
  374. }
  375. $.addClass(btn, "disabled");
  376. };
  377.  
  378. CFRQ.sortThreadsByReply = function() {
  379. //Thread sorting by report count
  380. var tempCounts = [];
  381. var tempThreads = [];
  382. for (var thread in CFRQ.threads) {
  383. tempCounts.push(CFRQ.threads[thread]);
  384. }
  385. tempCounts.sort(function(a, b) {
  386. return b - a;
  387. });
  388.  
  389. for (var i = 0; (thread = tempCounts[i]); ++i) {
  390. for (var x in CFRQ.threads) {
  391. if (CFRQ.threads[x] == thread ) {
  392. tempThreads.push(x);
  393. delete CFRQ.threads[x];
  394. }
  395. }
  396. }
  397.  
  398. CFRQ.sortedThreads = tempThreads;
  399. return;
  400. };
  401.  
  402. CFRQ.filterThreads = function() {
  403. var header, headers = $.cls("cfrq-thread-header");
  404. if (headers.length) {
  405. $.toggleXls($.id("cfrq-threads"), "disabled");
  406. for (var i = 0; (header = headers[i]); ++i) {
  407. //header.parentNode.removeChild(header);
  408. $.toggleXls(header, "hidden-i");
  409. }
  410.  
  411. return; //stop
  412. }
  413.  
  414. $.toggleXls($.id("cfrq-threads"), "disabled");
  415.  
  416. var thread, report;
  417. for (i = 0; (thread = CFRQ.sortedThreads[i]); ++i) {
  418. var reports = $.qsa('article[cfrq-parent="' + thread + '"]');
  419. if (reports.length > 1 || $.hasClass(reports[0], "report-cat-prio")) {
  420. header = $.el("header");
  421. var board = thread.split("-")[0];
  422. var tid = thread.split("-")[1];
  423. var boardLink = `<a href="${window.RQ.linkToPost(board, tid, 0)}" target="_blank">&gt;&gt;/${board}/${tid}</a>`;
  424. header.innerHTML = `${reports.length} ${$.pluralise(reports.length, " report", " reports")} for ${boardLink}`;
  425. header.className = "cfrq-thread-header";
  426. header.id = "cfrq-th-" + thread;
  427. $.id("items").insertBefore(header, $.id('items').childNodes[i]);
  428. }
  429. }
  430.  
  431. reports = $.qsa('article[cfrq-parent="' + thread + '"]');
  432. header = $.el("header");
  433. header.innerHTML = `Other Reports`;
  434. header.className = "cfrq-thread-header";
  435. header.id = "cfrq-th-remainder";
  436. $.id("items").insertBefore(header, $.id('items').childNodes[CFRQ.sortedThreads.length]);
  437.  
  438. for (i = 0; (thread = CFRQ.sortedThreads[i]); ++i) { //fix me
  439. reports = $.qsa('article[cfrq-parent="' + thread + '"]');
  440. for (var j = 0; (report = reports[j]); ++j) { //Add thread reports under header
  441. $.id('items').removeChild(report);
  442. var th_id = $.id("cfrq-th-" + thread);
  443. if (th_id) {
  444. $.id("items").insertBefore(report, th_id.nextSibling);
  445. } else {
  446. $.id("items").insertBefore(report, $.id("cfrq-th-remainder").nextSibling);
  447. }
  448. }
  449. }
  450. };
  451.  
  452. CFRQ.resetFilter = function() {
  453. var report, reports = $.cls("report");
  454. for (var i = 0; (report = reports[i]); ++i) {
  455. if ($.hasClass(report, "hidden-i")) $.removeClass(report, "hidden-i");
  456. }
  457. };
  458.  
  459. CFRQ.clearTooltips = function() {
  460. $.qsa(".tip-top").forEach(function(top) {
  461. try {
  462. top.parentNode.removeChild(top);
  463. } catch (e) {
  464. //shut up
  465. }
  466. });
  467. };
  468.  
  469. CFRQ.onScroll = function() {
  470. var st = window.pageYOffset || document.documentElement.scrollTop;
  471. if (st > 20 && window.RQ.settings.autoScrollNav){
  472. $.id('menu').style = 'position:fixed;top:0;right:0;left:0;z-index:99;';
  473. } else {
  474. if (window.pageYOffset < 20 || !window.RQ.settings.autoScrollNav) $.id('menu').style = '';
  475. }
  476. };
  477.  
  478. CFRQ.parseContext = function() {
  479. var i;
  480. var content = $.id("context-preview");
  481. if (!CFRQ.viewThread) {
  482. for (i = 0; i < content.childNodes.length; i++) {
  483. if (!content.childNodes[i].classList.contains("focused")) {
  484. content.childNodes[i].classList.add("hidden");
  485. } else {
  486. CFRQ.parseQuotelinks(content.childNodes[i], content.childNodes[0].id.split("-")[2], CFRQ.contextStart[0]);
  487. }
  488. }
  489. var post = $.id("context-" + CFRQ.contextStart[0] + "-" + CFRQ.contextStart[2]);
  490. //if post is null, it's because we've opened the context for a different thread than the original post
  491. if (post) {
  492. CFRQ.contextShow(post, CFRQ.contextStart[1], CFRQ.contextStart[0]);
  493. }
  494. } else {
  495. for (i = 0; i < content.childNodes.length; i++) {
  496. CFRQ.parseQuotelinks(content.childNodes[i], content.childNodes[0].id.split("-")[2], content.childNodes[i].id.split("-")[1]);
  497. }
  498. }
  499. };
  500.  
  501. CFRQ.contextHide = function(post, resto, board) {
  502. $.addClass(post, "hidden");
  503. $.removeClass(post, "focused");
  504. var quotelinks = $.cls("quotelink", post);
  505. for (var i = 0; i < quotelinks.length; i++) {
  506. if (quotelinks[i].getAttribute("data-target")) {
  507. var npost = $.id("context-" + board + "-" + quotelinks[i].getAttribute("data-target"));
  508. if (!npost.classList.contains("hidden")) {
  509. CFRQ.contextHide(npost, resto, board);
  510. }
  511. }
  512. }
  513. };
  514.  
  515. CFRQ.contextShow = function(post, resto, board) {
  516. $.removeClass(post, "hidden");
  517. CFRQ.parseQuotelinks(post, resto, board);
  518. };
  519.  
  520. CFRQ.toggleContextPost = function(board, resto, no) {
  521. var post = $.id("context-" + board + "-" + no);
  522. if ($.hasClass(post, "hidden")) {
  523. CFRQ.contextShow(post, resto, board);
  524. $.addClass(post, "focused");
  525. return true;
  526. } else {
  527. CFRQ.contextHide(post, resto, board);
  528. return false;
  529. }
  530. };
  531.  
  532. CFRQ.toggleContextFocus = function(board, resto, no) {
  533. $.id("context-" + board + "-" + no).classList.add("focused");
  534. };
  535.  
  536. CFRQ.quotelinkClick = function (btn) {
  537. var board = btn.getAttribute('data-board');
  538. var resto = btn.getAttribute('data-resto');
  539. var no = btn.getAttribute('data-target');
  540. var tmp;
  541. if (RQ.mode != RQ.MODE_CONTEXT) {
  542. CFRQ.viewThread = false;
  543. CFRQ.contextStart = [];
  544. CFRQ.contextStart.push(board);//start post board
  545. CFRQ.contextStart.push(resto);//start post resto
  546. tmp = (btn.parentNode.parentNode.id.split("-")[2] ? btn.parentNode.parentNode.id.split("-")[2] : btn.parentNode.parentNode.parentNode.id.split("-")[2]);//start post no
  547. CFRQ.contextStart.push(tmp);
  548. window.RQ.showContext(board, resto, no);
  549. } else {
  550. if (CFRQ.viewThread) {
  551. var focus = $.cls("focused", btn.parentNode.parentNode.parentNode.parentNode);
  552. for (var i = 0; i < focus.length; i++) focus[i].classList.remove("focused");
  553.  
  554. var nf = $.id("context-" + btn.getAttribute('data-board') + "-" + btn.getAttribute('data-target'));
  555. if (nf) {
  556. nf.classList.add("focused");
  557. nf.scrollIntoView();
  558. } else {
  559. window.RQ.showContext(board, resto, no);
  560. }
  561. } else {
  562. if (CFRQ.toggleContextPost(board, resto, no)) {
  563. btn.parentNode.parentNode.classList.remove("focused");
  564. } else {
  565. btn.parentNode.parentNode.classList.add("focused");
  566. }
  567. }
  568. }
  569. };
  570.  
  571. CFRQ.onClick = function(el) {
  572. var t = el.target;
  573. switch(t.getAttribute("data-cmd")) {
  574. case "show-context":
  575. CFRQ.viewThread = true;
  576. break;
  577. case "cfrq-quotelink":
  578. CFRQ.quotelinkClick(t);
  579. break;
  580. default: break;
  581. }
  582. };
  583.  
  584. //modified helpers.js
  585. if($)$.remByID=function(e){var n=$.id(e);n&&n.parentNode.removeChild(n)};else{var $={id:function(e){return document.getElementById(e)},remByID:function(e){var n=$.id(e);n&&n.parentNode.removeChild(n)},cls:function(e,n){return(n||document).getElementsByClassName(e)},byName:function(e){return document.getElementsByName(e)},tag:function(e,n){return(n||document).getElementsByTagName(e)},el:function(e){return document.createElement(e)},el2:function(e,n,t,i){var o,r;for(r in o=$.el(e),t)o.setAttribute(r,t[r]);return i&&(o.innerHTML=i),n.appendChild(o)},frag:function(){return document.createDocumentFragment()},qs:function(e,n){return(n||document).querySelector(e)},qsa:function(e,n){return(n||document).querySelectorAll(e)},extend:function(e,n){for(var t in n)e[t]=n[t]}};document.documentElement.classList?($.hasClass=function(e,n){return e.classList.contains(n)},$.addClass=function(e,n){e.classList.add(n)},$.removeClass=function(e,n){e.classList.remove(n)}):($.hasClass=function(e,n){return-1!=(" "+e.className+" ").indexOf(" "+n+" ")},$.addClass=function(e,n){e.className=""===e.className?n:e.className+" "+n},$.removeClass=function(e,n){e.className=(" "+e.className+" ").replace(" "+n+" ","")}),$.on=function(e,n,t){e.addEventListener(n,t,!1)},$.dispatch=function(e,n){var t=document.createEvent("Event");t.initEvent(e,!1,!1),document.dispatchEvent(t)},$.off=function(e,n,t){e.removeEventListener(n,t,!1)},$.xhr=function(e,n,t,i,o,r){var s,c,a;if(o=!!o||0,(c=new XMLHttpRequest).open(e,n,!0),t)for(s in t)c[s]=t[s];if(i)if("string"==typeof i)c.setRequestHeader("Content-type","application/x-www-form-urlencoded");else{for(s in a=new FormData,i)a.append(s,i[s]);i=a}else i=null;return o&&(c.withCredentials=!0),c.send(i),c},$.getItem=function(e){return localStorage.getItem(e)},$.setItem=function(e,n){return localStorage.setItem(e,n)},$.removeItem=function(e){return localStorage.removeItem(e)},$.getCookie=function(e){var n,t,i,o;for(o=e+"=",i=document.cookie.split(";"),n=0;t=i[n];++n){for(;" "==t.charAt(0);)t=t.substring(1,t.length);if(0===t.indexOf(o))return decodeURIComponent(t.substring(o.length,t.length))}return null},$.toggleXls=function(e,n){$.hasClass(e,n)?$.removeClass(e,n):$.addClass(e,n)},$.getToken=function(){return document.body.getAttribute("data-tkn")},$.capitalise=function(e){return e.charAt(0).toUpperCase()+e.slice(1)},$.pluralise=function(e,n,t){return 1===e?n||"":t||"s"},$.prettyBytes=function(e){return e>=1048576?(0|e/1048576*100+.5)/100+" MB":e>1024?(0|e/1024+.5)+" KB":e+" B"},$.ago=function(e){var n,t,i,o;return(n=Date.now()/1e3-e)<1?"1 sec":60>n?(0|n)+" secs":3600>n?(t=0|n/60)>1?t+" mins":"1 min":86400>n?(i=(t=0|n/3600)>1?t+"":"1",i+="."+(o=0|n/60-60*t)+" hrs"):(i=(t=0|n/86400)>1?t+"":"1",(o=0|n/3600-24*t)>=1&&(i+="."+o+" days"),i+"")},$.now=function(){return Math.round((new Date).getTime()/1e3)},$.length=function(e){return Object.keys(e).length},$.hidden="hidden",$.visibilitychange="visibilitychange",void 0===document.hidden&&("mozHidden"in document?($.hidden="mozHidden",$.visibilitychange="mozvisibilitychange"):"webkitHidden"in document?($.hidden="webkitHidden",$.visibilitychange="webkitvisibilitychange"):"msHidden"in document&&($.hidden="msHidden",$.visibilitychange="msvisibilitychange")),$.docEl=document.documentElement}
  586. var states = ["complete", "loaded", "interactive"];
  587. if (states.indexOf(document.readyState) != -1) CFRQ.addFilters();
  588. $.on(document, "4chanReportsReady", CFRQ.refresh);
  589. $.on(document, "4chanReportContextReady", CFRQ.parseContext);
  590. $.on(document, "scroll", CFRQ.onScroll);
  591. $.on(document, "click", CFRQ.onClick);
  592. CFRQ.fetchBoardList();
  593. })();
  594.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement