All pastes #1762668 Raw Edit

Anonymous

public javascript v1 · immutable
#1762668 ·published 2010-01-23 10:29 UTC
rendered paste body
// ==UserScript==// @name           MCL Pixup Copy// @namespace      bravo/greasemonkey// @description    Pixup copy function// @include        http://mycoffeelounge.net/pix*// @include        http://*.mycoffeelounge.net/pix*// @include        http://mycoffeelounge.net/forum-replies*// @include        http://*.mycoffeelounge.net/forum-replies*// @version        1.0.0// ==/UserScript==// getByIdfunction $xu(p, c) {	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;}// create Elementfunction $ec(type, attributes){	var node = document.createElement(type);	for (var attr in attributes) if (attributes.hasOwnProperty(attr)){		node.setAttribute(attr, attributes[attr]);	}	return node;}function $t(s) {	return document.createTextNode(s);}// make element first child of parfunction $ef(newNode, par) {	return par.insertBefore(newNode, par.firstChild);}// make element last child of parfunction $el(newNode, par) {	return par.appendChild(newNode);}function $getPos(element) {	var p = {x: element.offsetLeft || 0, y:element.offsetTop || 0};	while (element = element.offsetParent) {		p.x += element.offsetLeft;		p.y += element.offsetTop;	}	return p;}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;	}};var msg=$el($ec('DIV', { style: 'background:yellow; color:black; border:solid 1px black; position:absolute; display:none; left:auto; width:auto; padding: 2px 3px;' }), document.body);$el($t('Sent'), msg);if(/forum-replies/i.test(document.location.href)){	var pA = document.querySelector('#qquote a');	if(pA){		pA.addEventListener('click', function(e){			localStorage.setItem('chromePUclick','true');			return true;		},false);	}}var na = navigator.userAgent;var naC = (na.indexOf('Safari')>-1 && na.indexOf('Chrome')>-1);if(/pixup\.php/i.test(document.location.href)) {	if(naC && localStorage['chromePUclick']){		var s = document.createElement('script');		s.innerHTML="localStorage.removeItem('chromePUclick','true');alert(opener);";		document.querySelector('body').appendChild(s);	}	else if(opener){		var dest=opener.document.getElementById('body1');		$xu('//input[@type="text"]').forEach(function(el) {			if(el.name != 'imager2') {				$ev.Add(el, 'mouseup', function(e) {					if(opener) {						dest.value += '\n'+ el.value +'\n';						var p=$getPos(el);						msg.style.left=(p.x-50)+'px';						msg.style.top=p.y+'px';						msg.style.display='block';						window.setTimeout(function() { msg.style.display='none'; }, 2000);					}				}, false);			}		});	}}if(/pixbrowse\.php/i.test(document.location.href)) {	if(naC && localStorage['chromePUclick']){		var s = document.createElement('script');		s.innerHTML="localStorage.removeItem('chromePUclick','true');alert(opener);";		document.querySelector('body').appendChild(s);	}	else if(opener){		var dest=opener.document.getElementById('body1');		$xu('//TD[@class="news"]/DIV/A[IMG]').forEach(function(el) {			var butt=$ef($ec('INPUT', { type: 'button', value: 'copy', style: 'background:transparent; color:blue; border:none; font-size:10px;cursor:pointer;' }), el.parentNode);			$ev.Add(butt, 'click', function(e) {				if(opener) {					dest.value += '\n'+ el.href +'\n';					var p=$getPos(e.target);					msg.style.left=(p.x-50)+'px';					msg.style.top=(p.y-10)+'px';					msg.style.display='block';					window.setTimeout(function() { msg.style.display='none'; }, 2000);				}			}, false);		});	}}