CpcsceneSpy

From CPCWiki - THE Amstrad CPC encyclopedia!
Jump to: navigation, search

Aim

Here is a little [| Greasmonkey ] script in order to spy cpcscene trolliner who change there pseudonyme all the time.


TODO

  • better visual
  • store and restore data every time in order to keep pseudo not in the actual content


code

// ==UserScript==
// @name cpcscenespy
// @namespace http://krusty.benediction.eu
// @description Un script vite fait/mal fait permettant d'espionner les troll-liner indelicats
// @include http://www.cpcscene.com/
// ==/UserScript==



/**
* Histoire de gagner du temps au dev mais pas a l'execution ....
* Recuperation de DOJO
*/
var script = document.createElement('script');
script.src="http://o.aolcdn.com/dojo/1.1.0/dojo/dojo.xd.js";
script.type="text/javascript";
document.getElementsByTagName('head')[0].appendChild(script);

var link = document.createElement('link');
link.rel = "stylesheet";
link.type= "text/css";
link.href="http://o.aolcdn.com/dojo/1.1.0/dijit/themes/tundra/tundra.css";
document.getElementsByTagName('head')[0].appendChild(link);


String.prototype.trim = function(){
return this.replace(/(?:^\s+|\s+$)/g, "") ;
}


//Wait until everything is loaded before trying to do anything
window.addEventListener(
'load', 
function(event) {


var dojo = unsafeWindow["dojo"];
var list = dojo.fromJson(GM_getValue('cpcscene_troller', '{}')) ;
list = {}; //TODO debug



dojo.query('table tr > td > span.blob').forEach(
function( troller ){ 
var ip = troller.id.trim() ;
var pseudo = troller.textContent.trim() ;

if ( list[ip] != undefined ){
if ( list[ip].indexOf(pseudo) == -1) list[ip].push( pseudo) ;
}else{
list[ip] = new Array( pseudo ) ;
}
});


GM_setValue('cpcscene_troller', dojo.toJson(list)) ;

// a priori dojo met le resultat en cache ...
dojo.query('table tr > td > span.blob').forEach(
function( troller ) {
troller.alt = " " ;

list[troller.id].forEach( 
function(pseudo){
troller.alt += pseudo + " " ;
});


troller.textContent = troller.alt ;
});

},
'false'
);