fades sigs
当前为
// ==UserScript==
// @name ETI Sig Fader
// @namespace pendevin
// @description fades sigs
// @include http://boards.endoftheinter.net/showmessages.php*
// @include http://archives.endoftheinter.net/showmessages.php*
// @include http://endoftheinter.net/inboxthread.php*
// @include https://boards.endoftheinter.net/showmessages.php*
// @include https://archives.endoftheinter.net/showmessages.php*
// @include https://endoftheinter.net/inboxthread.php*
// @require http://code.jquery.com/jquery-2.1.3.min.js
// @version 1
// @grant none
// ==/UserScript==
//this is the opacity level you want in percentage. 100 is fully opaque (normal). 0 is fully transparent.
const SIG_OPACITY = 50;
//ll breaks without noconflict jquery
this.$ = this.jQuery = jQuery.noConflict(true);
//adds a style to a document and returns the style object *JQUERY
//css is a string, id is an optional string that determines the object's id
function addStyle(css, id) {
//create a style
var style = $('<style type="text/css">');
//add the css data to it
style.html(css);
if (id) {
//remove any style that has our id
$('#' + id).remove();
//give our style the id after removing the other stuff. idk if it matters, but i'm too lazy to find out
style.attr('id', id);
}
//add the style into the head
$('head').append(style);
//we're outta here
return style;
}
//livelinks compatiblity *JQUERY
//calls the function on each message-container in a document, including ones added by livelinks
//place is an optional specialized location
function livelinks(func, extraParams, place) {
if (extraParams == undefined) {
extraParams = null;
}
if (place == undefined) {
place = '#u0_1 .message-container';
}
//run the function on the message-containers currently on the page
$(place).each(function(i, container) {
func(container, extraParams);
});
//run it on any message-containers added in the future
$('#u0_1').on(
'DOMNodeInserted',
extraParams,
function(e) {
if ($(e.target).children('.message-container').length) {
$(e.target).children('.message-container').each(function(i, container) {
func(container, e.data);
});
}
}
);
}
//separate out the sigs
function processPosts(place) {
place = $(place);
//make sig container
var sig = $('<div class="sig">');
place.append(sig);
//stuff junk in sig container
var sigged = false;
place.contents().each(function(i, node) {
if (sigged) {
sig.append(node);
} else {
//this uses the first instance of the sig belt hmmmmm
if (node.textContent == '\n---') {
sigged = true;
sig.append(node);
}
}
});
//place.html(text.substring(0, text.lastIndexOf('\n---\n')) + '<div class="sig">' + text.substring(text.lastIndexOf('\n---\n') + 1) + '</div>');
}
//fade the sigs
var css = '\
.sig{\
opacity:' + SIG_OPACITY / 100 + ';\
}\
';
addStyle(css, 'sigFader');
//activate the thing
livelinks(processPosts, null, 'td.message');