There are 1 previous version of this script.
// ==UserScript==
// @name Simple Whirlpool Avatar
// @namespace http://forums.whirlpool.net.au/JBAvatar
// @description Uses Meatsack and Yansky's avatars
// @version 2.2.0
// @include http://forums.whirlpool.net.au/forum-replies.cfm?*
// @include http://whirlpool.net.au/forum-replies.cfm?*
// ==/UserScript==
function $i(id) { // getById
return document.getElementById(id);
}
function $x(p, c) { // xpath unordered nodes
var i, r = [], x = document.evaluate(p, c || document, null, XPathResult.UNORDERED_NODE_ITERATOR_TYPE, null);
while(i=x.iterateNext()) r.push(i);
return r;
}
function $xo(p, c) { // xpath ordered nodes
var i, r = [], x = document.evaluate(p, c || document, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null);
while(i=x.iterateNext()) r.push(i);
return r;
}
function $xf(p, c) { // xpath single first node
return document.evaluate(p, c || document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
}
function $xa(p, c) { // xpath single any node
return document.evaluate(p, c || document, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue;
}
function $t(s) { // text node
return document.createTextNode(s);
}
function $e(type, attributes) { // create Element
var node = document.createElement(type);
for (var attr in attributes) if (attributes.hasOwnProperty(attr)){
node.setAttribute(attr, attributes[attr]);
}
return node;
}
function $ed(element) { // delete Element
element.parentNode.removeChild(element);
}
function $ea(newNode, node) { // insert element after
return node.parentNode.insertBefore(newNode, node.nextSibling);
}
function $eb(newNode, node) { // insert element before
return node.parentNode.insertBefore(newNode, node);
}
function $ef(newNode, par) { // make element first child of par
return par.insertBefore(newNode, par.firstChild);
}
function $el(newNode, par) { // make element last child of par
return par.appendChild(newNode);
}
var $ev= {
_registry: null,
Initialise: function() {
if (this._registry == null) {
this._registry = [];
$ev.Add(window, "_unload", this.CleanUp);
}
},
Add: function(obj, type, fn, useCapture) {
this.Initialise();
var realType=(type=="_unload"?"unload":type);
if (typeof obj == "string") obj = document.getElementById(obj);
if (obj == null || fn == null) return false;
if(obj.addEventListener) obj.addEventListener(realType, fn, useCapture);
this._registry.push({obj:obj, type:type, fn:fn, useCapture:useCapture});
return true;
},
CleanUp: function() {
for (var i = 0; i < $ev._registry.length; i++) {
with($ev._registry[i]) {
if(type=="unload") fn();
if(obj.removeEventListener) obj.removeEventListener(type,fn,useCapture);
}
}
$ev._registry = null;
}
};
// -- start common config --
function __config() {
var xx=$i('__back__');
var yy=$i('__config_back__');
xx.style.display=xx.style.display == 'block' ? 'none' : 'block';
yy.style.display=xx.style.display;
}
if(! $i('__config__') ) {
$el($e('DIV', {
'id' : '__back__',
'style' : 'position: fixed; top: 0; left: 0; z-index: 9998; width:100%; height:100%; background: black; opacity: 0.7; display:none;'
}),document.body);
$el($e('DIV', {
'id' : '__config_back__',
'style' : 'position: fixed; top: 0; left: 0; z-index: 9999; width:100%; height:100%;'+
'background: transparent;font-size:16px; display:none;'
}),document.body);
$el($e('DIV', {
'id' : '__config_header__',
'style' : 'width: 100%; text-align:center; font-size:2.6em; font-weight:bold;color: white;'
}),$i('__config_back__'));
$el($e('DIV', {
'id' : '__config__',
'style' : 'width: 100%; position:fixed; z-index:10000; background: transparent;top:3em;bottom:0;'
}), $i('__config_back__'));
$el($e('DIV', { 'style' : 'clear:both;' }), $i('__config__'));
$el($e('DIV', {
'style' : 'font-size: 0.6em; position:fixed; z-index:10000; top:5px; right: 5px; color:white: font-weight:bold; background:red;'+
'-moz-border-radius:8px; padding: 0 6px; cursor:pointer;',
'id' : '__config_close__'
}),$i('__config_header__'));
$el($t('Greasemonkey Scripts Setup'), $i('__config_header__'));
$el($t('X'), $i('__config_close__'));
$ev.Add($i('__config_close__'), 'click', __config, false);
}
function _config_addBlock(s) {
var r = $eb($e('DIV', {
'style' : 'width:22%; margin:0 0 10px 10px; padding: 10px 8px; border: inset 2px yellow;background:#8888dd;-moz-border-radius:9px;' +
'float:left;'
}),$i('__config__').lastChild);
$el($t(s), $el($e('H2', { 'style' : 'text-align:center; margin:0 0 0.4em;' }), r));
return r;
}
// -- end common config --
// -- start WP config common --
if(! $i('__GMWP__')) {
var tDL=$xa('//div[@id="footer"]/DL[@class="wikilist"]');
if(tDL) {
var tDT=$i('gm_config');
if(! tDT ) {
tDT=$el($e('DT', { 'id' : 'gm_config'} ),tDL);
$el($t('Greasemonkey'), tDT);
}
var tDD = $el($e('DD', { 'style': 'cursor: pointer;', id: '__GMWP__'}),tDL);
$el($t('Configuration'),tDD);
$ev.Add(tDD, "click", __config, false);
}
}
// -- end WP config common --
function addStyle(s, id, disable) {
var e=$el($e('STYLE', { 'type' : 'text/css' }), document.getElementsByTagName('HEAD')[0]);
if(id) e.id=id;
$el($t(s), e);
if(disable) e.disabled = 'disabled';
return e;
}
var b=[
"data:image/png;base64,",
"iVBORw0KGgoAAAANSUhEUgAAABQAAAABCAYAAADeko4lAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9gE",
"FgoSD1eXcvUAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAO0lEQVQI1wXBsQGAIAwAsBSXwn3+fwZ0kZoE3gjV7YSo1mcYdd3iOXy1rNr2sda0",
"dyIxGcnNCLNbCvMHhQEYTyMYKXEAAAAASUVORK5CYII="
].join('');
//GM_addStyle('@import "http://ideatriage.com/files/wlrtheme/rank/small/themex2.css";');
//GM_addStyle('@import "http://ideatriage.com/wlr/avatar/avatar.css";');
GM_addStyle('td.bodyuser > div:first-child > a:first-child { margin:0 auto; }');
GM_addStyle('@import "http://goodbyepolar.com/wpavatars/avatar.css";');
GM_addStyle('TD.bodytext {vertical-align: top !important;}');
GM_addStyle('#replies tr .bodyuser div div:last-child:before { padding:5px 0 0; }');
GM_addStyle('tr.In_the_penalty_box > td.bodyuser {background-image:url('+b+')!important;background-repeat:repeat !important;');
addStyle('@import url(http://goodbyepolar.com/wpavatars/animatedavatar.css);', '__animated', GM_getValue('animated', 'yes') != 'yes');
$x('//TD[@class="bodyuser"]/DIV[contains(@style,"color:")]').forEach(function(d) {
d.parentNode.parentNode.className += " " + d.textContent.replace(/ /g, '_');
d.appendChild(document.createElement('DIV'));
});
var u='/forum-user.cfm?id=';
$x('//TD[@class="bodyuser" or @class="bodyuser_u"]/DIV/A[contains(@href,"'+u+'")]').forEach(function(a) {
var l=a.getAttribute('href');
a.parentNode.parentNode.parentNode.className += " wlr_" + l.substr(l.indexOf(u)+u.length);
var n=document.createElement('DIV');
n.innerHTML='<A href="'+l+'"></A>';
a.parentNode.parentNode.insertBefore(n, a.parentNode.parentNode.firstChild);
});
$x('//TD[@class="bodyuser_u"]').forEach(function(td) {
td.className = 'bodyuser '+td.className;
});
{
var cfg=_config_addBlock('Avatars');
var tEl=cfg.appendChild($e('LABEL', { 'for' : '__animated__' }));
tEl.appendChild(document.createTextNode('Enable Animated Avatars'));
tEl=cfg.appendChild($e('INPUT', { 'style':'text-align:right;', 'type':'checkbox', 'id':'__animated__'}));
if (GM_getValue('animated', 'yes') == 'yes') tEl.checked = 'checked';
$ev.Add(tEl, 'click', function() {
GM_setValue('animated', $i('__animated__').checked ? 'yes' : 'no');
$i('__animated').disabled = $i('__animated__').checked ? '' : 'disabled';
}, false);
}
