I'm making a userscript, like this:
[center]texthi[/center]
but when the text has spaces, the userscript ignores it.
It is based on Antidote:
// ==UserScript==
// @name Servines ATS
// @namespace http://www.scratch.mit.edu/
// @description Advanced Text Styling for Scratch!
// @include *
// ==/UserScript==
var version = 10;
if (document.URL.indexOf('http://scratch.mit.edu/forums/viewtopic.php') != -1) {
//replace important tags
var bodyElement = document.getElementsByTagName("body")[0];
var bodyInner = bodyElement.innerHTML;
var imageurls = new Array();
for (i=0;i<bodyInner.split(/\[important\]/i).length-1;i++) {
imageurls[i] = bodyInner.split(/\[important\]/i)[i+1].split(/\[\/important\]/i)[0];
if (imageurls[i].replace(/[a-zA-Z0-9\-_]+/, "") !== ""){
imageurls[i] = 'Undefined';
}
}
var toPrint = bodyInner;
for (i=0;i<imageurls.length;i++) {
toPrint = toPrint.replace(/\[important\]([a-zA-Z0-9\-_]+)\[\/important\]/i, '<b><u>'+ imageurls[i] + '</u></b>');
}
//replace centering
var centertags = new Array();
for (i=0;i<toPrint.split(/\[center\]/i).length-1;i++) {
centertags[i] = toPrint.split(/\[center\]/i)[i+1].split(/\[\/center\]/i)[0];
if (centertags[i].replace(/[a-zA-Z0-9\-_]+/, "") !== "") {
centertags[i] = 'Undefined';
}
}
for (i=0;i<centertags.length;i++) {
toPrint = toPrint.replace(/\[center\]([a-zA-Z0-9\-_]+)\[\/center\]/i, '<center>' + centertags[i] + '</center>');
}
//replace project tags
var projectpath = new Array();
for (i=0;i<toPrint.split(/\[scratch=flash\]/i).length-1;i++) {
projectpath[i] = toPrint.split(/\[scratch=flash\]/i)[i+1].split(/\[\/scratch\]/i)[0];
if (projectpath[i].replace(/[a-zA-Z0-9]+\/[0-9]+/i, "") !== "") {
projectpath[i] = 'Mike16112/675815';
}
}
for (i=0;i<projectpath.length;i++) {
toPrint = toPrint.replace(/\[scratch=flash\]([a-zA-Z0-9]+\/[0-9]+)\[\/scratch\]/i, '<object width="483" height="387" type="application/x-shockwave-flash" data="http://scratch.mit.edu/static/misc/PlayerOnly.swf"><param name="allowScriptAccess" value="always"><param name="allowFullScreen" value="true"><param name="flashvars" value="project=http://scratch.mit.edu/static/projects/' + projectpath[i] + '.sb?version=1"></object>');
}
document.getElementsByTagName("body")[0].innerHTML = toPrint;
document.getElementsByTagName("body")[0].innerHTML = document.getElementsByTagName("body")[0].innerHTML.replace(/antidoteexists=false/ig, 'antidoteexists=true&version=' + version);
}[important]HELP[/important]
Last edited by Servine (2012-08-23 11:34:27)
Offline
Offline
Ecliptic wrote:
Oh.
But it wont get that much notice. I kinda need it ASALN (As soon as... Like Now!
)
Offline