Anonymous ID: 79e309 March 31, 2019, 6:17 p.m. No.5997889   🗄️.is 🔗kun   >>7911 >>7975

jsanon here

 

this post contains a userscript for Greasemonkey, Tampermonkey, etc that makes some improvements to the breads

 

more info about userscripts and how to install them: https://github.com/OpenUserJs/OpenUserJS.org/wiki/Userscript-Beginners-HOWTO

 

features so far: highlight all lb/pb links in yellow, assign colors to user IDs

 

pic related

 

 

 

// —————– BEGIN SCRIPT

 

// UserScript

// @name qresearch tweaks by jsanon

// @version 7671

// @grant none

// @include https://8ch.net/qresearch/*

// /UserScript

 

(function() {

/**

  • Highlight lb/pb links in yellow

*/

var postId = window.location.href.match(/\/(\d+).html/)[1];

var style = document.createElement('style');

style.innerHTML = `

a[href^="/qresearch/res/"]:not([href^="/qresearch/res/${postId}.html"]) {

background: #ffb;

}

`;

document.querySelector('head').appendChild(style);

 

/**

  • Color user IDs

*/

var opID = document.querySelector('.post.op .poster_id').innerText.trim();

function colorUserIDs() {

Array.from(document.querySelectorAll('span.poster_id:not(.poster_id_colored)'))

.forEach(el ={

var c = el.innerText.trim(); // get hex color code

var rgb = parseInt(c, 16); // convert rrggbb to decimal

var r = (rgb >16) & 0xff; // extract red

var g = (rgb > 8) & 0xff; // extract green

var b = (rgb > 0) & 0xff; // extract blue

var luma = 0.2126 * r + 0.7152 * g + 0.0722 * b; // perceived brightness

el.style.background = '#' + el.innerText.trim();

if (luma < 128) {

el.style.color = '#fff';

}

el.style.borderRadius = '3px';

el.style.padding = '1px 2px';

el.classList.add('poster_id_colored');

if (c === opID) {

el.innerHTML += ' (OP)';

el.style.fontWeight = 'bold';

}

});

}

colorUserIDs();

setInterval(colorUserIDs, 2000);

})();

 

// —————– END SCRIPT

Anonymous ID: 79e309 March 31, 2019, 6:25 p.m. No.5998002   🗄️.is 🔗kun

>>5997975

>Userids are already colored, did you know that?

Thanks anon, I did not know 8ch had an option for this. No need to include it in my code then I guess. Will revise for next version.

 

I'm also going to see if I can fix loading of .jpeg images from previous breads.