Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //================================================================
- //
- // Toastmaster 2.4.0
- // Finds the bread so you don't have to.
- //
- // Always look through the code to find shifty stuff.
- //
- //
- //================================================================
- //2345678901234567890123456789012345678901234567890123456789012345
- /* 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=";
- 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): [];
- }
- var container = (_n('postcontrols'))[0];
- 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') != -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;
- function make_toast(url, time) {
- var response;
- var x = new XMLHttpRequest();
- x.open('GET', url, true);
- x.onreadystatechange = function() {
- 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;
- if (typeof txt == 'undefined') {
- txt = bread.com;
- if (txt.length > 40) {
- txt = txt.substring(0,39) + '...';
- }
- }
- var num = get_bread_number(txt);
- if (false == num) 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.
- }
- }
- var colors = ((thread[0].value == bread.no)
- ? ((posts < 750)
- ? ["#04ae04", "white", "black"]
- : ["#ae0404", "white", "black"])
- : ["#fefefe", "green", "red"]);
- 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');
- 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 dythreads = _i('dythreads');
- if (container && ! 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;
- };
- refresh();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement