Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * q.js v2018.3-2
- * http://anonsw.github.io/8chjs/
- */
- // Settings
- var qflair = ''; // Examples: REAL, →
- var qcolor = '#ffc';
- var youcolor = '#fcc';
- var scrollcolor = 'rgba(153, 153, 153, 0.6)';
- var scrollbackcolor = '#333';
- var scrolltime = 400; // ms
- var updateDelay = 200; // ms
- var sidenavWidth = 20; // px
- var floodEnabled = true;
- var floodThreshold = 15; // min # posts before beginning fade
- var floodVanish = 25; // max # posts before completed fade/hide
- var floodBehavior = 'fade'; // hide, fade
- var rateHistoryLen = 50; // Data points on chart
- var rateAvgLen = 10; // Number of data points to average for instantaneous rate
- /* House keeping variables */
- var qposts = [];
- var allqposts = [];
- var currq = -1;
- var youposts = [];
- var curryou = -1;
- var qnavposts = [];
- var younavposts = [];
- var ctx;
- var borderSz;
- var scrollWd;
- var minheight;
- var ratehistory = [];
- // Suggestions from 589388.html#590283
- // ...shill detection features, such as
- // easily knowing the proportion of posts from a user that don't link.
- // I'd want to know any ID that was posting > 1/3 posts targetting noone.
- // TODO: Behavior for post hover should be to show original post visual before all q.js mods
- // TODO: Add flags to turn on/off features
- // TODO: Auto-filter/shade? Custom-regexes?
- // Ex. If post has Q's trip code as name, auto-filter/shade post and responses
- // TODO: Custom-regex -> post color/fade (auto-filter by selecting text and choosing new menu item?)
- // Examples: daily reminder, guys, check this out, shill, get out, filtered, tell us more, archive everything
- // TODO: Manual shade
- // TODO: remove Q trip codes from post content?
- // TODO: remove Q from end of post content if not a Q post?
- // TODO: recognize all of known Q trip codes? (make to sure to exclude known comps)
- // TODO: Links to reset on current Q/(you) post
- // TODO: Link to go to latest post (end key doesn't always work, but try capturing that as well?)
- // TODO: Keyboard shortcuts for navigation
- // TODO: Current/Total overall post navigation
- // TODO: Remap end key to always go to end of page
- // TODO: Check box for each post to mark as "read", "spam", ?
- // TODO: Autocorrect all-caps posts (50% threshold)?
- // TODO: Correct broken links but remove referral when clicked?
- // TODO: Make flood post fading non-linear to give leniency to posters just passing flood threshold
- // TODO: Penalize reposts in flood detection (if id's different, merge?) ?
- // TODO: Scorecard of posters orderd by post count (post rate, reply count, ...)?
- // TODO: Color/shade posts where there are no references and no question marks
- // TODO: If Q or trip used in name field, strike them out or replace with Anonymous?
- // TODO: embedded posts in Q posts don't have background-color and inherit Q color, fix?
- /* Case insensitive contains selector for finding yous. SO #8746882 */
- jQuery.expr[":"].icontains = jQuery.expr.createPseudo(function (arg) {
- return function (elem) {
- return jQuery(elem).text().toUpperCase().indexOf(arg.toUpperCase()) >= 0;
- };
- });
- /* Display a replies counter overlay in the top right corner */
- $(function(){
- $('head').append('<style>#thread_stats_posts_ovl { '+
- 'position:fixed;top:35px;right:35px;'+
- 'font:38px sans-serif;opacity:0.5;color:#f60;}</style>');
- $('body').append('<div id="thread_stats_posts_ovl"/>');
- function copyStats() { $('#thread_stats_posts_ovl').
- text($('#thread_stats_posts').text());}
- $(document).on('new_post',copyStats); copyStats();});
- /* On scroll stop. SO #9144560 */
- (function ($) {
- var on = $.fn.on, timer;
- $.fn.on = function () {
- var args = Array.apply(null, arguments);
- var last = args[args.length - 1];
- if (isNaN(last) || (last === 1 && args.pop())) return on.apply(this, args);
- var delay = args.pop();
- var fn = args.pop();
- args.push(function () {
- var self = this, params = arguments;
- clearTimeout(timer);
- timer = setTimeout(function () {
- fn.apply(self, params);
- }, delay);
- });
- return on.apply(this, args);
- };
- }(this.jQuery || this.Zepto));
- /* Scroll to element */
- function myScrollTo(el) {
- $('html, body').animate({
- scrollTop: $(el).offset().top - $('div.boardlist').height()
- }, scrolltime);
- }
- /* Highlight you references */
- function highlightYouRefs() {
- $('div.body:icontains("(You)")').each(function() {
- $(this).parents('div.post').first().css('background-color',youcolor);
- });
- return $.Deferred().resolve();
- }
- // Set which posts are (you) posts
- function setYouPosts() {
- youposts = $.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(el) {
- return $(el).closest('div.post');
- });
- return $.Deferred().resolve();
- }
- /* Remove invalid (you)'s */
- function removeInvalidYous() {
- $('div.body:icontains("(You)")').each(function() {
- $(this).find(':not(small)').contents().filter(function() { return this.nodeType == 3 }).each(function() {
- this.textContent = this.textContent.replace(/\(+ *You *\)+/ig, "you");
- });
- });
- return $.Deferred().resolve();
- }
- /* Highlight Q posts */
- function highlightQ() {
- $(allqposts).each(function(idx,val) {
- var div = $(val).parents('div.post').first();
- if($(div).css('background-color') !== qcolor) {
- if(qflair !== "") {
- $(val).prepend(qflair + " ");
- }
- $(div).css('background-color', qcolor);
- }
- });
- return $.Deferred().resolve();
- }
- /* Scroll to next Q */
- function nextq() {
- if(qposts.length > 0) {
- if(currq < qposts.length-1) {
- currq++;
- }
- myScrollTo($(qposts).get(currq));
- }
- }
- /* Scroll to last Q */
- function lastq() {
- if(qposts.length > 0) {
- currq = qposts.length - 1;
- myScrollTo($(qposts).get(currq));
- }
- }
- /* Scroll to previous Q */
- function prevq() {
- if(qposts.length > 0) {
- if(currq > 0) {
- currq--;
- }
- myScrollTo($(qposts).get(currq));
- }
- }
- /* Scroll to first Q */
- function firstq() {
- if(qposts.length > 0) {
- currq = 0;
- myScrollTo($(qposts).get(currq));
- }
- }
- /* Scroll to next (You) */
- function nextyou() {
- if(youposts.length > 0) {
- if(curryou < youposts.length-1) {
- curryou++;
- }
- myScrollTo($(youposts).get(curryou));
- }
- }
- /* Scroll to last (You) */
- function lastyou() {
- if(youposts.length > 0) {
- curryou = youposts.length - 1;
- myScrollTo($(youposts).get(curryou));
- }
- }
- /* Scroll to previous (You) */
- function prevyou() {
- if(youposts.length > 0) {
- if(curryou > 0) {
- curryou--;
- }
- myScrollTo($(youposts).get(curryou));
- }
- }
- /* Scroll to first (You) */
- function firstyou() {
- if(youposts.length > 0) {
- curryou = 0;
- myScrollTo($(youposts).get(curryou));
- }
- }
- /* Inserts Q navigation links */
- function qnav() {
- $('div.boardlist').append('<span>[ <a href="javascript:firstq();"><i class="fa fa-step-backward"></i></a> <a href="javascript:prevq();"><i class="fa fa-backward"></i></a> <span style="filter:brightness(70%);">Q</span> <span class="qcount">(?:?)</span> <a href="javascript:nextq();"><i class="fa fa-forward"></i></a> <a href="javascript:lastq();"><i class="fa fa-step-forward"></i></a> ]</span>');
- }
- /* Inserts (You) navigation links */
- function younav() {
- $('div.boardlist').append('<span>[ <a href="javascript:firstyou();"><i class="fa fa-step-backward"></i></a> <a href="javascript:prevyou();"><i class="fa fa-backward"></i></a> <span style="filter:brightness(70%);">(You)</span> <span class="youcount">(?:?)</span> </span><a href="javascript:nextyou();"><i class="fa fa-forward"></i></a> <a href="javascript:lastyou();"><i class="fa fa-step-forward"></i></a> ]</span>');
- }
- /* Inserts feature toggle links */
- function togglenav() {
- $('div.boardlist').append('<span>[ <a href="javascript:toggleFlood();">Turn Post Fading <span class="toggleFloodState">Off</span></a> ]</span>')
- }
- function postratenav() {
- var height = $('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 charts = $('.postRateChart');
- $(charts).each(function() {
- $(this).css('width', '100px');
- $(this).css('height', height);
- $(this).css('vertical-align', 'middle');
- //$(this).css('border', '1px solid');
- //$(this).css('border-color', $('div.boardlist').css('color'));
- var gctx = $(this).get(0).getContext('2d');
- gctx.canvas.height = 20;
- gctx.canvas.width = 100;
- });
- }
- /* Inserts side navigation */
- function sidenav() {
- $('body').append('<canvas id="sidenav"></canvas>');
- var nav = $('#sidenav');
- $(nav).css('position', 'fixed');
- $(nav).css('top', $('div.boardlist').height());
- $(nav).css('right', 0);
- $(nav).css('width', sidenavWidth);
- $(nav).css('height', $(window).height() - $('div.boardlist').height());
- $(nav).css('background-color', scrollbackcolor);
- $('body').css('margin-right', sidenavWidth);
- ctx = $('#sidenav').get(0).getContext('2d');
- //ctx.canvas.height = $(document).height() - $('div.boardlist').height();
- ctx.canvas.height = 2048;
- ctx.canvas.width = sidenavWidth;
- borderSz = 1;
- scrollWd = ctx.canvas.width / 2;
- }
- /* Update navigation counts */
- function updateNavCounts() {
- var fontSize = -1;
- var lineHeight;
- if(currq > qposts.length) { currq = qposts.length; }
- if(curryou > youposts.length) { curryou = youposts.length; }
- for(i=0; i<qposts.length; i++) {
- var el = $(qposts).get(i);
- if(fontSize == -1) {
- fontSize = $(el).css('font-size');
- lineHeight = Math.floor(parseInt(fontSize.replace('px', '')) * 1.5);
- }
- if(($(el).offset().top + $(el).height() - 2.25*lineHeight) > $(window).scrollTop()) {
- currq = i;
- break;
- }
- }
- for(i=0; i<youposts.length; i++) {
- var el = $(youposts).get(i);
- if(fontSize == -1) {
- fontSize = $(el).css('font-size');
- lineHeight = Math.floor(parseInt(fontSize.replace('px', '')) * 1.5);
- }
- if(($(el).offset().top + $(el).height() - 2.25*lineHeight) > $(window).scrollTop()) {
- curryou = i;
- break;
- }
- }
- // TODO: check for duplicates and remove from counts
- $('.qcount').text("(" + (currq+1) + ":" + qposts.length + ")");
- $('.youcount').text("(" + (curryou+1) + ":" + youposts.length + ")");
- }
- /* Update navigation graphics */
- function updateNavGraphics() {
- var sidenav = $('#sidenav');
- if(sidenav.length) {
- $(sidenav).css('height', $(window).height() - $('div.boardlist').height());
- minheight = ctx.canvas.height / ($(window).height() - $('div.boardlist').height()); // 1px
- ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
- // Draw nav q posts
- qnavposts = [];
- ctx.fillStyle = qcolor;
- for (i = 0; i < qposts.length; i++) {
- // TODO: check if we have already added post, don't draw it again
- var el = $(qposts).get(i);
- var height = $(el).height() / $(document).height() * ctx.canvas.height;
- if(height < minheight) height = minheight;
- qnavposts[i] = {
- x : borderSz,
- y : $(el).offset().top / $(document).height() * ctx.canvas.height,
- width : ctx.canvas.width - borderSz*2,
- height : height
- };
- ctx.fillRect(qnavposts[i].x, qnavposts[i].y, qnavposts[i].width, qnavposts[i].height);
- }
- // Draw nav you posts
- younavposts = [];
- ctx.fillStyle = youcolor;
- for (i = 0; i < youposts.length; i++) {
- // TODO: check if we have already added post, don't add it again
- var el = $(youposts).get(i);
- var height = $(el).height() / $(document).height() * ctx.canvas.height;
- if(height < minheight) height = minheight;
- younavposts[i] = {
- x : borderSz,
- y : $(el).offset().top / $(document).height() * ctx.canvas.height,
- width : ctx.canvas.width - borderSz*2,
- height : height
- };
- ctx.fillRect(younavposts[i].x, younavposts[i].y, younavposts[i].width, younavposts[i].height);
- }
- // Update nav window
- ctx.fillStyle = scrollcolor;
- ctx.fillRect(
- scrollWd / 2,
- $(window).scrollTop() / $(document).height() * ctx.canvas.height,
- scrollWd,
- $(window).height() / $(document).height() * ctx.canvas.height
- );
- // Add red marker at bottom of >750 posts
- if($('#thread_stats_posts').text() > 750) {
- var barHeight = (4 * 2048) / ($(window).height() - $('div.boardlist').height());
- ctx.fillStyle = '#f66';
- ctx.fillRect(
- 0,
- ctx.canvas.height - barHeight,
- ctx.canvas.width,
- barHeight
- );
- }
- }
- }
- function updateNavPostRate() {
- var posts = $('div.post').not('.post-hover');
- var startPost = posts.length - (rateHistoryLen + rateAvgLen) + 1;
- if(startPost < 1) startPost = 1;
- var start = $($($(posts).get(0)).find('.intro time').get(0)).attr('unixtime'); //$('div.post:first .intro time').attr('unixtime');
- ratehistory = [];
- timehistory = [];
- for(var i=startPost; i<posts.length; i++) {
- // TODO: check if we have already added post, don't add it again
- var step = $($($(posts).get(i)).find('.intro time').get(0)).attr('unixtime'); //$($('div.post .intro time').get(i)).attr('unixtime');
- timehistory[timehistory.length] = step;
- if(timehistory.length - rateAvgLen - 1 >= 0) {
- var avgend = timehistory[timehistory.length - 1];
- var avgstart = timehistory[timehistory.length - rateAvgLen - 1];
- ratehistory[ratehistory.length] = rateAvgLen / ((avgend - avgstart) / 60);
- } else {
- ratehistory[ratehistory.length] = 0;
- }
- }
- //console.log(ratehistory);
- $('.postRate').text(ratehistory[ratehistory.length-1].toFixed(1));
- if(ratehistory.length > rateAvgLen) {
- var maxRate = Math.max.apply(null, ratehistory);
- var minRate = Math.min.apply(null, ratehistory);
- //console.log("Max: " + maxRate);
- //console.log("Min: " + minRate);
- if(minRate > (maxRate - 0.5)) {
- minRate = maxRate - 0.5;
- maxRate = maxRate + 0.5;
- }
- if(minRate < 0) {
- minRate = 0;
- }
- var maxTime = timehistory[timehistory.length-1];
- var minTime = timehistory[rateAvgLen];
- $('.postRateChart').each(function() {
- var gctx = $(this).get(0).getContext('2d');
- gctx.clearRect(0, 0, gctx.canvas.width, gctx.canvas.height);
- gctx.strokeStyle = $('div.boardlist a').css('color');
- gctx.beginPath();
- var x = 0;
- var y = gctx.canvas.height - (ratehistory[rateAvgLen] - minRate)/(maxRate - minRate) * gctx.canvas.height;
- gctx.moveTo(x, y);
- for(var i=rateAvgLen+1; i<ratehistory.length; i++) {
- x = (timehistory[i] - minTime)/(maxTime - minTime) * gctx.canvas.width;
- y = gctx.canvas.height - (ratehistory[i] - minRate)/(maxRate - minRate) * gctx.canvas.height;
- gctx.lineTo(x, y);
- }
- gctx.stroke();
- gctx.closePath();
- });
- }
- }
- /* Update navigation */
- function updateNav() {
- updateNavCounts();
- updateNavGraphics();
- updateNavPostRate();
- }
- // Update nav when scrolling stops
- $(window).on('scroll', function(e) {
- updateNavCounts();
- updateNavGraphics();
- }, updateDelay);
- // Update nav when resize stops
- $(window).on('resize', function(e) {
- updateNav();
- }, updateDelay);
- /* Set which posts are Q posts */
- function setQPosts() {
- qposts = $.map($('div.post span.trip:contains("!!mG7VJxZNCI"):visible').not('.post-hover'), function(el) {
- return $(el).parents('div.post').first();
- });
- allqposts = $('span.trip:contains("!!mG7VJxZNCI")');
- return $.Deferred().resolve();
- }
- /* Set which posts are you posts */
- function setYouPosts() {
- youposts = $.map($('div.post span.own_post,div.body:icontains("(You)")').not('.post-hover'), function(el) {
- return $(el).parents('div.post').first();
- });
- return $.Deferred().resolve();
- }
- function setFloodPosts() {
- if(floodEnabled) {
- var stats = {};
- var firstId = null;
- $('span.poster_id').each(function () {
- var id = $(this).text();
- if (!(id in stats)) {
- stats[id] = {count: 0};
- }
- stats[id].count++;
- if (firstId == null) {
- firstId = id;
- }
- });
- $.each(stats, function (key, value) {
- if (key != firstId) {
- if (value.count > floodThreshold) {
- if (floodBehavior === 'fade') {
- var intensity = value.count;
- if (intensity > floodVanish) {
- intensity = floodVanish;
- }
- intensity = ((floodVanish - floodThreshold) - (intensity - floodThreshold)) / (floodVanish - floodThreshold);
- if (intensity < 0.1) {
- intensity = 0.1;
- }
- $('span.poster_id:contains("' + key + '")').each(function () {
- $(this).parents('div.post').first().css('opacity', intensity);
- $(this).parents('div.post').first().hover(function () {
- $(this).animate({opacity: 1.0}, updateDelay);
- }, function () {
- $(this).animate({opacity: intensity}, updateDelay);
- });
- });
- } else if (floodBehavior === 'hide') {
- if (value.count >= floodVanish) {
- $('span.poster_id:contains("' + key + '")').each(function () {
- $(this).parents('div.post').first().hide();
- });
- }
- }
- }
- }
- });
- }
- return $.Deferred().resolve();
- }
- function toggleFlood() {
- if(floodEnabled) {
- floodEnabled = false;
- $('.toggleFloodState').text('On');
- if(floodBehavior === 'fade') {
- $('span.poster_id').each(function () {
- $(this).parents('div.post').first().css('opacity', 1);
- $(this).parents('div.post').first().off('mouseenter mouseleave');
- });
- } else if(floodBehavior === 'hide') {
- $(this).parents('div.post').first().show();
- }
- } else {
- floodEnabled = true;
- $('.toggleFloodState').text('Off');
- runq()
- }
- }
- /* Helper to run snippets in the right order */
- function runq() {
- setQPosts()
- .done(highlightQ)
- .done(removeInvalidYous)
- .done(highlightYouRefs)
- .done(setYouPosts)
- .done(setFloodPosts)
- .done(updateNav);
- }
- /* Attach snippets to ready/change events */
- $(document).ready(function() {
- qnav();
- younav();
- togglenav();
- postratenav();
- sidenav();
- runq();
- // Select the node that will be observed for mutations
- var targetNode = $('div.thread')[0];
- // Options for the observer (which mutations to observe)
- var config = { childList: true };
- // Callback function to execute when mutations are observed
- var callback = function(mutationsList) {
- for(var mutation of mutationsList) {
- if (mutation.type == 'childList') {
- runq();
- break;
- }
- }
- };
- // Create an observer instance linked to the callback function
- var observer = new MutationObserver(callback);
- // Start observing the target node for configured mutations
- observer.observe(targetNode, config);
- });
- //================================================================
- //
- // Toastmaster 2.5.2
- // Finds the bread so you don't have to.
- //
- // Always look through the code to find shifty stuff.
- //
- //
- //================================================================
- //2345678901234567890123456789012345678901234567890123456789012345
- /*
- these files can be extracted and saved as text and they should
- still be loadable
- */
- var container;
- /* this is literally just a picture of toast */
- var toast = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABsAA"
- + "AAbCAMAAAC6CgRnAAAARVBMVEWZMwAAAABmMwBmMzNmZjOZZgCZ"
- + "ZjOZZmbMZgDMZjPMZmaZmTOZmWbMmTPMmWbMmZn/mWbMzGbMzJn"
- + "/zGb/zJn/zMz//8zDFCa2AAAAAXRSTlMAQObYZgAAAAlwSFlzAA"
- + "ALEwAACxMBAJqcGAAAAAd0SU1FB+IIBAI4ECHmtE4AAAFKSURBV"
- + "CjPVVIBcsMwCKubQuZb0J2xu/8/dRJJt5ZzcnGEhAy+3V7R3uL2"
- + "FtrfffN927a7P+7tDYEDuRiZ4II/LrQ5EQwQKVAp8HZCBu6Jrpm"
- + "5JpiST+ytBGFBovIrB5iDX3RECCKKh+SDSoxEYaYtWVEkhkdgCl"
- + "uBTmIO2kHwr015m6mCqROMkMwsOcjOurwERYbcpBDrgfyBsPpDM"
- + "VHLiVTYifJ5sEiWKs6FoLtRPo+ijXI4aazzvGEvrHJXnAcgyi9b"
- + "wiyrm8mKKUCS5IJnaPFfpXrHWt27xyqsV8Fuhu5yadHDIcy+7eK"
- + "xWVaaqKyz15IHaWFfTjkhvTQpEp1pxmWdc+aL7D/M1F1a57l6KI"
- + "GwNPuCrOZ5tlVvCsU4edX6+he8E+xY5bWaA0eX6+BgBq/SwfGz/"
- + "2EahAbLGgd8Z/92v0JD+rjQH/ELBU8elOTZkAQAAAAASUVORK5C"
- + "YII=";
- /* this is an MP3 file. you should inspect it yourself */
- var frog = "data:audio/wav;base64,UklGRjkKAABXQVZFZm10IBAAAAABA"
- + "AEAQB8AAEAfAAABAAgAZGF0YRUKAAB9fn1+gIGDhIOAf4B/gH+B"
- + "goGCgYKBf4CAf4B/gIGDgoGCf4B+foGCgYKBfnx9f3+AgoGCgoK"
- + "Af35/gYB/f4B/foKDhIOEg398fYB+fH6BgoGCgX9+foGCgYKCgH"
- + "17e3yAhISCgYOEg4GAfHuAg4SDgH+BgoGBg4aEf31/f3x8foB9e"
- + "XuAgoCAg4aFgoF+e3p8f4B8foOBf4GEgn6Ag4N+f4SDe3d+gn1+"
- + "h4h8e4aLh4GDhoB4eoB+eX6HhXx8g4R8fIODgX+Cgnp3foF8fYS"
- + "Ggn+BgHp4en6Af4CBf4GEgoCCh4V+en2CgX6DiYh+eH6BfICMjo"
- + "J4eXl4gIuLhIGDfnV7hYeDhYh9b3F9gn+Bh4Z7dX+Ef3+Lint0f"
- + "YN8e4SFeniDiYB5g4d/foaEdnqJjH58iId4eIaGeHqIhXR1hYh6"
- + "dn+Ce3qFiod9d4CGgnp+hYF5e4WHgYGHhHd2goiDg4uNf3iBhHt"
- + "7iZCDdnl8dneGjYF3fHtzdIKKhH+Afnd0eoOFfXd+iIN7hY2Acn"
- + "aEiImPjn1rboCTlo+Gdm5veIuYmY59Z11shJaenIVnX2NqgZ2fi"
- + "315bGV4kIp2f457aH2UgmyDnodqe5WCaIKkjGVymIxjcaCdbWSN"
- + "l25gi6aFYXWUelx8p5RocJiKXWidqHdghp1zWIKumWlumJNiYJe"
- + "vfll9m3FTga2NWG+ce1F5sp5kaZiDV3avr3lohXVQZp6ynYmBal"
- + "xxhYSOoZRwbY6KYGiXlm1/r5RbZY95V4i+oF9hinJMe7mra2KFa"
- + "Ul6urBwZIpyTXu1omVxpIhYdq2RV26upGJjoJ1bWZ61d1SKqW1M"
- + "jsSVUG2jdUN8w6FQXpx7RXnAolhtoHRMgbyfZXqZZEBy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uI9sn"
- + "bp7RGCUdUBuv712Xo2HOz+e2KhfgqVhMWaxqXJ4n4BVbJGVhoKH"
- + "hHp3fIGEhoJ+fHx2cHJ2dnV+i46GhIuJd2pxfoCBjJiRgXx+end"
- + "9io+Dd4CSlIh5cnBjW26MlpGTloRhUWeHg3qXtJtpYHmAamqLm4"
- + "qEmJBlV298am2dwKZwZnprTWyzwpWBnpNSPXSbcFWb2adTUYVoJ"
- + "FzS8ZlVgY5AJXS7pG6Do31cdZeUhn55e4OLioODiYd9dXd7f4KF"
- + "hYSBenNxdnh3eH+Ki4WBgn54en6AgomSkIiDhIJ7dnd8f4KKlJe"
- + "Qf29pYVtke5ajnIRtYF9sgY2Up7amhG5tbGNpjq2lj4N1VzY9a4"
- + "yZtNzPgUtMUD5QpOXSloeFUjBelH1zvNOAQnKaPQV/9+GCf8Z7A"
- + "BOo5oNkoqVTRIejkn94e4aLiYSFjIt+cm5wdHV6hIaCg4iLgnV3"
- + "gn98jJuWhH+CfGtkeI+NfX2RnZJ7bWtjYX6aknqAmpd6Y2h2fYi"
- + "ZopN/eoB6aWiAjoiLnqGDZGZza197q7WYhox9T0F6rJh7nruGRF"
- + "mafCZM1emXa621OgBB39mPi6eeXE1vioV/gYGAf4CAgoF/gH+Bg"
- + "oB/";
- function _i(o) {
- return (o) ? document.getElementById(o) : null;
- }
- function _n(o) {
- return (o) ? document.getElementsByName(o) : [];
- }
- function _t(o) {
- return (o) ? document.getElementsByTagName(o) : [];
- }
- function _$(o) {
- return (o) ? document.getElementsByClassName(o): [];
- }
- function _c(ob,id) {
- switch(ob) {
- case 'DIV':
- case 'SPAN':
- case 'INPUT':
- var ob = document.createElement(ob);
- ob.id = id;
- break;
- case 'LABEL':
- var ob = document.createElement(ob);
- ob.setAttribute('for', id);
- break;
- default:
- ob.appendChild(document.createTextNode(id));
- }
- return ob;
- }
- function css(s, j) {
- for(var k in j) {
- s.style[k] = j[k];
- }
- }
- function filter_by_id() {
- var id = _i('search_input').value;
- var list = _$('poster_id');
- var node;
- var valid;
- for(var i = 0; i < list.length; i++) {
- node = (list[i].parentNode.parentNode);
- valid = (-1 == node.innerText.indexOf(id));
- node.style.display=(valid)?'none':'inline-block';
- if (node.nextSibling) {
- node.nextSibling.style.display=(valid)?'none':'inline';
- }
- }
- }
- function get_bread_number(text) {
- if ( (text.toLowerCase().indexOf('ebake') != -1)
- || (text.toLowerCase().indexOf('q research general') != -1)) {
- var rx = /[^0-9]*([0-9]+)[^0-9]*/g;
- var arr = rx.exec(text);
- return arr && arr.length > 1 ? arr[1] : false;
- }
- return false;
- }
- window.colored = 0;
- window.all_breads = {};
- function make_toast(url, time) {
- var response;
- var x = new XMLHttpRequest();
- x.open('GET', url, true);
- if (typeof window.all_breads[url] == 'undefined') {
- window.all_breads[url] = 0;
- }
- if (window.all_breads[url] > 751 || window.all_breads[url] == -1) {
- return;
- }
- if (url == '#') {
- var opt = _c('SPAN', "ribbit");
- var container = _i('dythreads');
- var colors = ["#fefefe", "green", "red"];
- css(opt,{
- font : 'normal normal bold 8px/15px '
- + '"Courier New", Courier, Monospace',
- float : 'right',
- color : colors[1],
- cursor : 'pointer',
- width : '49px',
- height : '13px',
- margin : '1px',
- border : '1px solid #b0b0b0',
- display : 'inline-block',
- filter : 'brightness(100%)',
- textAlign : 'left',
- textIndent : '9px',
- borderRadius : '3px',
- verticalAlign : 'top',
- backgroundSize : '13px'
- });
- opt.innerHTML = "RIBBIT!"
- + " <span style='font-weight:bold;color:"
- + colors[2]
- + ";'>"
- + "</span>";
- container.appendChild(opt);
- opt.onclick = function () {
- var snd = new Audio(frog);
- snd.play();
- };
- return;
- }
- else x.onreadystatechange = function() {
- var that = url;
- if(x.readyState === 4 && x.status == 200) {
- response = JSON.parse(x.responseText);
- var container = _i('dythreads');
- var bread = response.posts[0];
- var posts = response.posts.length;
- var txt = bread.sub;
- window.all_breads[url] = posts;
- if (typeof txt == 'undefined') {
- txt = bread.com;
- if (txt.length > 40) {
- txt = txt.substring(0,39) + '...';
- }
- }
- var num = get_bread_number(txt);
- // skip this bread forever
- if (false == num) {
- window.all_breads[that] = -1;
- return;
- }
- var thread = _n('thread');
- var hrefs = _t('A');
- for(var i = window.colored; i < hrefs.length; i++) {
- if (-1 == hrefs[i].href.indexOf("res/" + thread[0].value+".html") &&
- -1 != hrefs[i].href.indexOf("qresearch")) {
- hrefs[i].style.color='#0077aa';
- window.colored = i; // don't color it twice.
- }
- }
- if (thread[0].value == bread.no) {
- var pfi = _i('post-form-inner');
- if (pfi && (posts > 750)) {
- css(pfi,{
- border :'3px solid red',
- padding :'3px',
- opacity : '0.7',
- background : 'url(data:image/png;base64,iVB'
- + 'ORw0KGgoAAAANSUhEUgAAAAQAAAAE'
- + 'CAYAAACp8Z5+AAAAGklEQVQIW2NkY'
- + 'GD4D8SMQAwGcAY2AbBKDBUAVuYCBQ'
- + 'Pd34sAAAAASUVORK5CYII=) repeat',
- borderRadius : '10px',
- });
- }
- }
- var opts = _n('toast');
- var colors = ((thread[0].value == bread.no)
- ? ((posts < 750)
- ? ["#04ae04", "white", "black"]
- : ["#ae0404", "white", "black"])
- : ["#fefefe", "green", "red"]);
- for(var i = 0; i < opts.length; i++) {
- if (opts[i].getAttribute('no') == bread.no) {
- opts[i].innerHTML = num
- + " <span style='font-weight:bold;color:"
- + colors[2]
- + "'>"
- + posts
- +"</span>";
- opts[i].style.background = colors[0]
- + " url("
- + toast
- + ") 0px 0px/25px 25px no-repeat";
- opts[i].style.backgroundSize = "13px";
- return;
- }
- }
- var opt = _c('SPAN', "" + bread.no);
- opt.setAttribute('no',bread.no);
- opt.addEventListener('mouseout',function() {
- css(opt,{
- cursor : 'pointer',
- filter : 'brightness(100%)'
- })
- });
- opt.addEventListener('mouseover',function() {
- css(opt,{
- cursor : 'auto',
- filter : 'brightness(80%)'
- })
- });
- css(opt,{
- font : 'normal normal bold 8px/15px '
- + '"Courier New", Courier, Monospace',
- float : 'right',
- color : colors[1],
- width : '59px',
- height : '13px',
- margin : '1px',
- border : '1px solid #b0b0b0',
- display : 'inline-block',
- filter : 'brightness(100%)',
- textAlign : 'left',
- textIndent : '18px',
- background : colors[0] + ' url(' + toast
- + ') 0px 0px/25px 25px no-repeat',
- borderRadius : '3px',
- verticalAlign : 'top',
- backgroundSize : '13px'
- });
- opt.innerHTML = num
- + " <span style='font-weight:bold;color:"
- + colors[2]
- + ";'>"
- + posts
- + "</span>";
- opt.id = "" + bread.no;
- container.appendChild(opt);
- opt.setAttribute('name','toast');
- opt.onclick = function () {
- var no = bread.no;
- if(typeof url != 'undefined') {
- window.location.href =
- '/qresearch/res/' + no + '.html';
- }
- };
- opt.setAttribute('old',false);
- }
- };
- x.send();
- }
- // every 60 seconds we reload from threads.json
- function refresh() {
- // prune expired breads and append new ones.
- var opts = _n('toast');
- for(var i = 0; i < opts.length; i++) {
- if (opts[i].getAttribute('old') == true) {
- container.removeChild(opts[i]);
- }
- else {
- opts[i].setAttribute('old',true);
- }
- }
- var x = new XMLHttpRequest();
- x.open('GET', "/qresearch/threads.json", true);
- x.onreadystatechange = function() {
- if(x.readyState === 4 && x.status == 200) {
- var response = JSON.parse(x.responseText);
- find_recent_bread(response);
- }
- };
- x.send();
- trips();
- }
- // Count instances of Q with trips, mark untripped Q's as fakes
- function trips() {
- var m = _i('notify');
- var t = 0;
- var k, r;
- var list = _$('trip');
- for(var i = 0; i < list.length; i++) {
- r = list[i].innerText.trim();
- if (list[i].parentNode.parentNode.className !='intro') continue;
- if (! r.length || r == 'FAKE') {
- continue;
- }
- k = list[i].previousSibling.innerText.trim();
- if (k == 'Q' || k == 'Q+') {
- t++;
- }
- }
- if (t) {
- m.innerHTML = "Q Posts (" + t + ")";
- }
- if ((t != window.t) && t) {
- m.animate([
- { color: 'red' },
- { color: 'white' },
- { color: 'blue' }
- ], {
- duration: 500,
- iterations: 17
- });
- window.t = t;
- }
- var list = _$('name');
- for(var i = 0; i < list.length; i++) {
- r = list[i].innerText.trim();
- k = list[i].nextSibling;
- if (k && k.className!='trip') {
- if (r == 'Q' || r == 'Q+') {
- list[i].innerHTML = r
- + " <span style='color:red'>[FAKE]</span>";
- }
- }
- }
- }
- function find_recent_bread(board) {
- var now = ~~((new Date).getTime() / 1000);
- var thread;
- for(var i = 0; i < board.length; i++) {
- for(var j = 0; j < board[i].threads.length; j++) {
- thread = board[i].threads[j];
- // only show threads modified within the last 2 hours
- if (now - thread.last_modified < 7200) {
- make_toast('/qresearch/res/'+thread.no + '.json',
- thread.last_modified);
- }
- }
- }
- }
- // Post controls is loaded and we're already in a thread
- // append the controls at the top, but only once.
- var toast_init = function() {
- container = (_n('postcontrols'))[0];
- var dythreads = _i('dythreads');
- if (! dythreads) {
- var box = _c('DIV', 'notify');
- var bar = _c('DIV', 'dythreads');
- var label = _c('LABEL', 'search_input');
- var text = _c(label, 'Search:');
- var search = _c('INPUT', 'search_input');
- container.appendChild(bar);
- bar.appendChild(label);
- bar.appendChild(search);
- bar.appendChild(box);
- css(bar,{
- top : '15px',
- width : 'calc(100% - 8px)',
- height : '16px',
- margin : '0 0 0 -16px',
- zIndex : '100',
- display : 'block',
- padding : '0 8px 0 16px',
- position : 'fixed',
- textAlign : 'left',
- background : '#eef2ff url(/stylesheets/img/fade-blue.png)'
- + ' repeat-x 50% 0%',
- borderBottom : '1px solid #b0b0b0'
- });
- css(search,{
- font : 'normal normal bold 8px/13px "Courier New", '
- + 'Courier, Monospace',
- float :'left',
- height :'9px',
- border :'none',
- marginTop :'2px'
- });
- css(label,{
- font : 'normal normal bold 8px/15px "Courier New", '
- + 'Courier, Monospace',
- float :'left',
- height : '13px',
- });
- css(box,{
- font : 'normal normal bold 8px/13px "Courier New", '
- + 'Courier, Monospace',
- color : 'red',
- width : '105px',
- float : 'left',
- height : '15px',
- margin : '2px 0 0 5px'
- });
- setInterval("refresh();", 5000);
- search.onkeyup =
- search.oninput =
- search.onchange =
- search.onkeydown = function(e) {
- var c;
- e = e || event;
- c = (e.keyCode || e.which || e.charCode || 0)
- if (c == 13) e.stopPropagation();
- if (window.to) clearTimeout(window.to);
- window.to = setTimeout(function() {
- filter_by_id();
- }, 1000);
- return c !== 13;
- };
- var auto = _i('auto_update_status');
- if (auto) {
- auto.setAttribute('checked',true);
- //auto.setPropertyuchecked = true;
- }
- refresh();
- make_toast('#',0);
- }
- }
- $(document).ready(toast_init);
Add Comment
Please, Sign In to add comment