rookwood101 wrote:
fungirl123 wrote:
ZeroLuck wrote:
Lol, that was me
You should disable it because everyone can get your account when you have this
not disabled!I did
Are people going to get into my account now??!?!
I'm so noobish lolno don't worry, zeroluck hasn't actually done anything with the cookie, just displayed it.
Still, might want to fix?
Offline
fixed! (only images at the moment though - you'll have to wait for me to fix the security holes in the youtube and scratch projects)
Only problem is, it won't work if the images have capital letters in their filename.
Download using the original link.
Offline
rookwood101 wrote:
fixed! (only images at the moment though - you'll have to wait for me to fix the security holes in the youtube and scratch projects)
Only problem is, it won't work if the images have capital letters in their filename.
Download using the original link.
read this it tells you how to update.
Offline
this post had some test stuff in.
Last edited by rookwood101 (2012-01-02 05:40:36)
Offline
MathWizz wrote:
@rookwood101, you have a second monitor the exact same size as me. 0.o
Wait what lol
Edit: not very anonymous 'anonymous usage statistics'?
Last edited by rookwood101 (2012-01-01 16:32:25)
Offline
roijac wrote:
you forgot my name
Lol sorry
Offline
Massive script update!
This post will hopefully explain to you what has changed, and also how to update your copy of the script to the latest version.
Me and LS97 put a lot of work into making this script safe and secure, removing all the security holes, and making sure everything works perfectly.
Changes:
Stopped people from being able to inject malicious JavaScript code that could potentially log in to your scratch account!
Features:
• Make all the image tags work again
- disagree with the scratch team's decision to disable all images in posts? You'll be able to
view them all now!
Uses the standard [ img ] and [ /img ] tags.
• Embed YouTube videos directly on the forums without linking through to any sites!
- show your friends that video you've been working on quickly and easily!
Uses a new tag formatted like so: [ youtube ]<video id>[ /youtube ]
Eg. [ youtube ]aZDG15hb[ /youtube ]
• Post scratch projects on the forums
- let the community know of your latest creation without even leaving the comfort of the
forums!
Uses another new tag formatted like this: [ scratch=flash ]<user>/<project id>[ /scratch ]
eg. [ scratch=flash ]rookwood101/123456[ /scratch ]
Remember not to have any spaces in the tags when you are actually using them as otherwise they will not work!
To update the script:
on firefox you can go into tools>greasemonkey>manage user scripts>then click remove on the one labeled 'enable images on scratch forums'.
In chrome go to the spanner icon, then click options, go to extensions and uninstall 'enable images on scratch forums'
You'll have to work out yourself how to do it in other browsers.
Finally just click the link in the first post to redownload the script!
Offline
rookwood101 wrote:
[...]
Remember not to have any spaces in the tags when you are actually using them as otherwise they will not work!
If you don't want to confuse Scratchers with the spaces in the [ img ] tags, you can type [[b][/b]img], which makes [img].
Offline
I added a notice on top which tells you whether the script was successful or not, and gives a bug report link if there is an error. (The header is also edited slightly)
// ==UserScript== // @name Image Enabler // @namespace rookwood101,Cocolover,LS97,flashgocrazy // @description Enable images, and allow Scratch projects and YouTube videos on forums with BBCode // @include http://scratch.mit.edu/forums/viewtopic.php* // ==/UserScript== //Set title to fail document.getElementById("brdtitle").innerHTML=document.getElementById("brdtitle").innerHTML+"<span id='imgtagenablerstatus'>Greasemonkey image tag enabler is goofing up. <small style='color:#777777'>[<a href='http://scratch.mit.edu/forums/viewtopic.php?id=85177' style='color:#777777'>Report this bug!</a>]</small></span>"; if (document.URL.indexOf('http://scratch.mit.edu/forums/viewtopic.php') != -1) { //replace img tags var bodyElement = document.getElementsByTagName("body")[0]; var bodyInner = bodyElement.innerHTML; var imageurls = new Array(); for (i=0;i<bodyInner.split(/\[img\]/i).length-1;i++) { imageurls[i] = bodyInner.split(/\[img\]/i)[i+1].split(/\[\/img\]/i)[0]; if (imageurls[i].replace(/(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?/i, "") != "") { imageurls[i] = 'http://img94.imageshack.us/img94/6045/invalidimage.png'; } } var addImages = bodyInner; for (i=0;i<imageurls.length;i++) { addImages = addImages.replace(/\[img\](http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?\[\/img\]/i, '<img style="max-width: 510px;" src="' + imageurls[i] + '" />'); } //replace youtube tags var youtubeids = new Array(); for (i=0;i<addImages.split(/\[youtube\]/i).length-1;i++) { youtubeids[i] = addImages.split(/\[youtube\]/i)[i+1].split(/\[\/youtube\]/i)[0]; if (youtubeids[i].replace(/[a-zA-Z0-9\-_]+/, "") != "") { youtubeids[i] = 'dQw4w9WgXcQ'; } } var addYoutube = addImages; for (i=0;i<youtubeids.length;i++) { addYoutube = addYoutube.replace(/\[youtube\]([a-zA-Z0-9\-_]+)\[\/youtube\]/i, '<iframe width="510" height="315" src="http://www.youtube.com/embed/' + youtubeids[i] + '"frameborder="0" allowfullscreen></iframe>'); } //replace project tags var projectpath = new Array(); for (i=0;i<addYoutube.split(/\[scratch=flash\]/i).length-1;i++) { projectpath[i] = addYoutube.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'; } } var addProjects = addYoutube; for (i=0;i<projectpath.length;i++) { addProjects = addProjects.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 = addProjects; } //Set title to success document.getElementById("imgtagenablerstatus").innerHTML="Greasemonkey image tag enabler has completed running. <small style='color:#777777'>[<a href='http://scratch.mit.edu/forums/viewtopic.php?id=85177' style='color:#777777'>Having problems?</a>]</small>";
Offline
need help debugging
// ==UserScript== // @name enable images on scratch forum and more! // @namespace rookwood101,Cocolover,LS97,flashgocrazy,roijac // @description enable images on scratch forum, added youtube and projects // @include http://scratch.mit.edu/forums/viewtopic.php* // ==/UserScript== if (document.URL.indexOf('http://scratch.mit.edu/forums/viewtopic.php') != -1) { //replace img tags var bodyElement = document.getElementsByTagName("body")[0]; var bodyInner = bodyElement.innerHTML; var imageurls = new Array(); for (i=0;i<bodyInner.split(/\[img\]/i).length-1;i++) { imageurls[i] = bodyInner.split(/\[img\]/i)[i+1].split(/\[\/img\]/i)[0]; if (imageurls[i].replace(/(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?/i, "") != "") { imageurls[i] = 'http://img94.imageshack.us/img94/6045/invalidimage.png'; } } var addImages = bodyInner; for (i=0;i<imageurls.length;i++) { addImages = addImages.replace(/\[img\](http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?\[\/img\]/i, '<img style="max-width: 510px;" src="' + imageurls[i] + '" />'); } //replace youtube tags var youtubeids = new Array(); for (i=0;i<addImages.split(/\[youtube\]/i).length-1;i++) { youtubeids[i] = addImages.split(/\[youtube\]/i)[i+1].split(/\[\/youtube\]/i)[0]; if (youtubeids[i].replace(/[a-zA-Z0-9\-_]+/, "") != "") { youtubeids[i] = 'dQw4w9WgXcQ'; } } var addYoutube = addImages; for (i=0;i<youtubeids.length;i++) { addYoutube = addYoutube.replace(/\[youtube\]([a-zA-Z0-9\-_]+)\[\/youtube\]/i, '<iframe width="510" height="315" src="http://www.youtube.com/embed/' + youtubeids[i] + '"frameborder="0" allowfullscreen></iframe>'); } //replace project tags var projectpath = new Array(); for (i=0;i<addYoutube.split(/\[scratch=flash\]/i).length-1;i++) { projectpath[i] = addYoutube.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'; } } function showProject(i) { projectDiv = document.getElementById(i); if(projectDiv.style.display == "block") { projectDiv.style.display = "none"; } else { projectDiv.style.display = "block"; } } var addProjects = addYoutube; for (i=0;i<projectpath.length;i++) { addProjects = addProjects.replace(/\[scratch=flash\]([a-zA-Z0-9]+\/[0-9]+)\[\/scratch\]/i, '<input type="button" value="Show/Hide Project" onclick="showProject(' + i + ');"/> <div id="' + i + '" style="display: none;"> <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> </div>'); } document.getElementsByTagName("body")[0].innerHTML = addProjects; }
tried preventing auto-playing, but doesn't work
Last edited by roijac (2012-01-02 13:33:10)
Offline
Hardmath123 wrote:
I added a notice on top which tells you whether the script was successful or not, and gives a bug report link if there is an error. (The header is also edited slightly)
Code:
// ==UserScript== // @name Image Enabler // @namespace rookwood101,Cocolover,LS97,flashgocrazy // @description Enable images, and allow Scratch projects and YouTube videos on forums with BBCode // @include http://scratch.mit.edu/forums/viewtopic.php* // ==/UserScript== //Set title to fail document.getElementById("brdtitle").innerHTML=document.getElementById("brdtitle").innerHTML+"<span id='imgtagenablerstatus'>Greasemonkey image tag enabler is goofing up. <small style='color:#777777'>[<a href='http://scratch.mit.edu/forums/viewtopic.php?id=85177' style='color:#777777'>Report this bug!</a>]</small></span>"; if (document.URL.indexOf('http://scratch.mit.edu/forums/viewtopic.php') != -1) { //replace img tags var bodyElement = document.getElementsByTagName("body")[0]; var bodyInner = bodyElement.innerHTML; var imageurls = new Array(); for (i=0;i<bodyInner.split(/\[img\]/i).length-1;i++) { imageurls[i] = bodyInner.split(/\[img\]/i)[i+1].split(/\[\/img\]/i)[0]; if (imageurls[i].replace(/(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?/i, "") != "") { imageurls[i] = 'http://img94.imageshack.us/img94/6045/invalidimage.png'; } } var addImages = bodyInner; for (i=0;i<imageurls.length;i++) { addImages = addImages.replace(/\[img\](http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?\[\/img\]/i, '<img style="max-width: 510px;" src="' + imageurls[i] + '" />'); } //replace youtube tags var youtubeids = new Array(); for (i=0;i<addImages.split(/\[youtube\]/i).length-1;i++) { youtubeids[i] = addImages.split(/\[youtube\]/i)[i+1].split(/\[\/youtube\]/i)[0]; if (youtubeids[i].replace(/[a-zA-Z0-9\-_]+/, "") != "") { youtubeids[i] = 'dQw4w9WgXcQ'; } } var addYoutube = addImages; for (i=0;i<youtubeids.length;i++) { addYoutube = addYoutube.replace(/\[youtube\]([a-zA-Z0-9\-_]+)\[\/youtube\]/i, '<iframe width="510" height="315" src="http://www.youtube.com/embed/' + youtubeids[i] + '"frameborder="0" allowfullscreen></iframe>'); } //replace project tags var projectpath = new Array(); for (i=0;i<addYoutube.split(/\[scratch=flash\]/i).length-1;i++) { projectpath[i] = addYoutube.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'; } } var addProjects = addYoutube; for (i=0;i<projectpath.length;i++) { addProjects = addProjects.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 = addProjects; } //Set title to success document.getElementById("imgtagenablerstatus").innerHTML="Greasemonkey image tag enabler has completed running. <small style='color:#777777'>[<a href='http://scratch.mit.edu/forums/viewtopic.php?id=85177' style='color:#777777'>Having problems?</a>]</small>";
You should probably put the extra code you added in the if statement, otherwise it will run on any page (in chome, not firefox).
But other than that, great! I tested it and it works perfectly!
I'll debug yours in a sec roijac (lunch)
Last edited by rookwood101 (2012-01-02 08:28:33)
Offline
rookwood101 wrote:
Hardmath123 wrote:
I added a notice on top which tells you whether the script was successful or not, and gives a bug report link if there is an error. (The header is also edited slightly)
Code:
// ==UserScript== // @name Image Enabler // @namespace rookwood101,Cocolover,LS97,flashgocrazy // @description Enable images, and allow Scratch projects and YouTube videos on forums with BBCode // @include http://scratch.mit.edu/forums/viewtopic.php* // ==/UserScript== //Set title to fail document.getElementById("brdtitle").innerHTML=document.getElementById("brdtitle").innerHTML+"<span id='imgtagenablerstatus'>Greasemonkey image tag enabler is goofing up. <small style='color:#777777'>[<a href='http://scratch.mit.edu/forums/viewtopic.php?id=85177' style='color:#777777'>Report this bug!</a>]</small></span>"; if (document.URL.indexOf('http://scratch.mit.edu/forums/viewtopic.php') != -1) { //replace img tags var bodyElement = document.getElementsByTagName("body")[0]; var bodyInner = bodyElement.innerHTML; var imageurls = new Array(); for (i=0;i<bodyInner.split(/\[img\]/i).length-1;i++) { imageurls[i] = bodyInner.split(/\[img\]/i)[i+1].split(/\[\/img\]/i)[0]; if (imageurls[i].replace(/(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?/i, "") != "") { imageurls[i] = 'http://img94.imageshack.us/img94/6045/invalidimage.png'; } } var addImages = bodyInner; for (i=0;i<imageurls.length;i++) { addImages = addImages.replace(/\[img\](http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?\[\/img\]/i, '<img style="max-width: 510px;" src="' + imageurls[i] + '" />'); } //replace youtube tags var youtubeids = new Array(); for (i=0;i<addImages.split(/\[youtube\]/i).length-1;i++) { youtubeids[i] = addImages.split(/\[youtube\]/i)[i+1].split(/\[\/youtube\]/i)[0]; if (youtubeids[i].replace(/[a-zA-Z0-9\-_]+/, "") != "") { youtubeids[i] = 'dQw4w9WgXcQ'; } } var addYoutube = addImages; for (i=0;i<youtubeids.length;i++) { addYoutube = addYoutube.replace(/\[youtube\]([a-zA-Z0-9\-_]+)\[\/youtube\]/i, '<iframe width="510" height="315" src="http://www.youtube.com/embed/' + youtubeids[i] + '"frameborder="0" allowfullscreen></iframe>'); } //replace project tags var projectpath = new Array(); for (i=0;i<addYoutube.split(/\[scratch=flash\]/i).length-1;i++) { projectpath[i] = addYoutube.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'; } } var addProjects = addYoutube; for (i=0;i<projectpath.length;i++) { addProjects = addProjects.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 = addProjects; } //Set title to success document.getElementById("imgtagenablerstatus").innerHTML="Greasemonkey image tag enabler has completed running. <small style='color:#777777'>[<a href='http://scratch.mit.edu/forums/viewtopic.php?id=85177' style='color:#777777'>Having problems?</a>]</small>";You should probably put the extra code you added in the if statement, otherwise it will run on any page (in chome, not firefox).
But other than that, great! I tested it and it works perfectly!
I'll debug yours in a sec roijac (lunch)
// ==UserScript== // @name Image Enabler // @namespace rookwood101,Cocolover,LS97,flashgocrazy // @description Enable images, and allow Scratch projects and YouTube videos on forums with BBCode // @include http://scratch.mit.edu/forums/viewtopic.php* // ==/UserScript== if (document.URL.indexOf('http://scratch.mit.edu/forums/viewtopic.php') != -1) { //Set title to fail document.getElementById("brdtitle").innerHTML=document.getElementById("brdtitle").innerHTML+"<span id='imgtagenablerstatus'>Greasemonkey image tag enabler is goofing up. There may be an open tag or invalid image. <small style='color:#777777'>[<a href='http://scratch.mit.edu/forums/viewtopic.php?id=85177' style='color:#777777'>Report this bug!</a>]</small></span>"; //replace img tags var bodyElement = document.getElementsByTagName("body")[0]; var bodyInner = bodyElement.innerHTML; if (occurrences(bodyInner, "[img]")<=30) { var imageurls = new Array(); for (i=0;i<bodyInner.split(/\[img\]/i).length-1;i++) { imageurls[i] = bodyInner.split(/\[img\]/i)[i+1].split(/\[\/img\]/i)[0]; if (imageurls[i].replace(/(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?/i, "") != "") { imageurls[i] = 'http://img94.imageshack.us/img94/6045/invalidimage.png'; } } var addImages = bodyInner; for (i=0;i<imageurls.length;i++) { addImages = addImages.replace(/\[img\](http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?\[\/img\]/i, '<img style="max-width: 510px;" src="' + imageurls[i] + '" />'); } } else { alert("There were too many images to display, so they have been omitted."); } //replace youtube tags var youtubeids = new Array(); for (i=0;i<addImages.split(/\[youtube\]/i).length-1;i++) { youtubeids[i] = addImages.split(/\[youtube\]/i)[i+1].split(/\[\/youtube\]/i)[0]; if (youtubeids[i].replace(/[a-zA-Z0-9\-_]+/, "") != "") { youtubeids[i] = 'dQw4w9WgXcQ'; } } var addYoutube = addImages; for (i=0;i<youtubeids.length;i++) { addYoutube = addYoutube.replace(/\[youtube\]([a-zA-Z0-9\-_]+)\[\/youtube\]/i, '<iframe width="510" height="315" src="http://www.youtube.com/embed/' + youtubeids[i] + '"frameborder="0" allowfullscreen></iframe>'); } //replace project tags var projectpath = new Array(); for (i=0;i<addYoutube.split(/\[scratch=flash\]/i).length-1;i++) { projectpath[i] = addYoutube.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'; } } var addProjects = addYoutube; for (i=0;i<projectpath.length;i++) { addProjects = addProjects.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 = addProjects; } //Set title to success document.getElementById("imgtagenablerstatus").innerHTML="Greasemonkey image tag enabler has completed running. <small style='color:#777777'>[<a href='http://scratch.mit.edu/forums/viewtopic.php?id=85177' style='color:#777777'>Having problems?</a>]</small>"; function occurrences(string, substring){ var n=0; var pos=0; while(true){ pos=string.indexOf(substring,pos); if(pos!=-1){ n++; pos+=substring.length;} else{break;} } return(n); }
Now it gives a "too many image tags" warning if there are 30+ images, and it bails out of the image processing bit. If you want, you can put a confirm() bypass, but I find this way cleaner.
Last edited by Hardmath123 (2012-01-02 08:39:48)
Offline
Hardmath123 wrote:
rookwood101 wrote:
Hardmath123 wrote:
I added a notice on top which tells you whether the script was successful or not, and gives a bug report link if there is an error. (The header is also edited slightly)
Code:
// ==UserScript== // @name Image Enabler // @namespace rookwood101,Cocolover,LS97,flashgocrazy // @description Enable images, and allow Scratch projects and YouTube videos on forums with BBCode // @include http://scratch.mit.edu/forums/viewtopic.php* // ==/UserScript== //Set title to fail document.getElementById("brdtitle").innerHTML=document.getElementById("brdtitle").innerHTML+"<span id='imgtagenablerstatus'>Greasemonkey image tag enabler is goofing up. <small style='color:#777777'>[<a href='http://scratch.mit.edu/forums/viewtopic.php?id=85177' style='color:#777777'>Report this bug!</a>]</small></span>"; if (document.URL.indexOf('http://scratch.mit.edu/forums/viewtopic.php') != -1) { //replace img tags var bodyElement = document.getElementsByTagName("body")[0]; var bodyInner = bodyElement.innerHTML; var imageurls = new Array(); for (i=0;i<bodyInner.split(/\[img\]/i).length-1;i++) { imageurls[i] = bodyInner.split(/\[img\]/i)[i+1].split(/\[\/img\]/i)[0]; if (imageurls[i].replace(/(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?/i, "") != "") { imageurls[i] = 'http://img94.imageshack.us/img94/6045/invalidimage.png'; } } var addImages = bodyInner; for (i=0;i<imageurls.length;i++) { addImages = addImages.replace(/\[img\](http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?\[\/img\]/i, '<img style="max-width: 510px;" src="' + imageurls[i] + '" />'); } //replace youtube tags var youtubeids = new Array(); for (i=0;i<addImages.split(/\[youtube\]/i).length-1;i++) { youtubeids[i] = addImages.split(/\[youtube\]/i)[i+1].split(/\[\/youtube\]/i)[0]; if (youtubeids[i].replace(/[a-zA-Z0-9\-_]+/, "") != "") { youtubeids[i] = 'dQw4w9WgXcQ'; } } var addYoutube = addImages; for (i=0;i<youtubeids.length;i++) { addYoutube = addYoutube.replace(/\[youtube\]([a-zA-Z0-9\-_]+)\[\/youtube\]/i, '<iframe width="510" height="315" src="http://www.youtube.com/embed/' + youtubeids[i] + '"frameborder="0" allowfullscreen></iframe>'); } //replace project tags var projectpath = new Array(); for (i=0;i<addYoutube.split(/\[scratch=flash\]/i).length-1;i++) { projectpath[i] = addYoutube.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'; } } var addProjects = addYoutube; for (i=0;i<projectpath.length;i++) { addProjects = addProjects.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 = addProjects; } //Set title to success document.getElementById("imgtagenablerstatus").innerHTML="Greasemonkey image tag enabler has completed running. <small style='color:#777777'>[<a href='http://scratch.mit.edu/forums/viewtopic.php?id=85177' style='color:#777777'>Having problems?</a>]</small>";You should probably put the extra code you added in the if statement, otherwise it will run on any page (in chome, not firefox).
But other than that, great! I tested it and it works perfectly!
I'll debug yours in a sec roijac (lunch)Code:
// ==UserScript== // @name Image Enabler // @namespace rookwood101,Cocolover,LS97,flashgocrazy // @description Enable images, and allow Scratch projects and YouTube videos on forums with BBCode // @include http://scratch.mit.edu/forums/viewtopic.php* // ==/UserScript== if (document.URL.indexOf('http://scratch.mit.edu/forums/viewtopic.php') != -1) { //Set title to fail document.getElementById("brdtitle").innerHTML=document.getElementById("brdtitle").innerHTML+"<span id='imgtagenablerstatus'>Greasemonkey image tag enabler is goofing up. There may be an open tag or invalid image. <small style='color:#777777'>[<a href='http://scratch.mit.edu/forums/viewtopic.php?id=85177' style='color:#777777'>Report this bug!</a>]</small></span>"; //replace img tags var bodyElement = document.getElementsByTagName("body")[0]; var bodyInner = bodyElement.innerHTML; if (occurrences(bodyInner, "[url]")<=30) { var imageurls = new Array(); for (i=0;i<bodyInner.split(/\[img\]/i).length-1;i++) { imageurls[i] = bodyInner.split(/\[img\]/i)[i+1].split(/\[\/img\]/i)[0]; if (imageurls[i].replace(/(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?/i, "") != "") { imageurls[i] = 'http://img94.imageshack.us/img94/6045/invalidimage.png'; } } var addImages = bodyInner; for (i=0;i<imageurls.length;i++) { addImages = addImages.replace(/\[img\](http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?\[\/img\]/i, '<img style="max-width: 510px;" src="' + imageurls[i] + '" />'); } } else { alert("There were too many images to display, so they have been omitted."); } //replace youtube tags var youtubeids = new Array(); for (i=0;i<addImages.split(/\[youtube\]/i).length-1;i++) { youtubeids[i] = addImages.split(/\[youtube\]/i)[i+1].split(/\[\/youtube\]/i)[0]; if (youtubeids[i].replace(/[a-zA-Z0-9\-_]+/, "") != "") { youtubeids[i] = 'dQw4w9WgXcQ'; } } var addYoutube = addImages; for (i=0;i<youtubeids.length;i++) { addYoutube = addYoutube.replace(/\[youtube\]([a-zA-Z0-9\-_]+)\[\/youtube\]/i, '<iframe width="510" height="315" src="http://www.youtube.com/embed/' + youtubeids[i] + '"frameborder="0" allowfullscreen></iframe>'); } //replace project tags var projectpath = new Array(); for (i=0;i<addYoutube.split(/\[scratch=flash\]/i).length-1;i++) { projectpath[i] = addYoutube.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'; } } var addProjects = addYoutube; for (i=0;i<projectpath.length;i++) { addProjects = addProjects.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 = addProjects; } //Set title to success document.getElementById("imgtagenablerstatus").innerHTML="Greasemonkey image tag enabler has completed running. <small style='color:#777777'>[<a href='http://scratch.mit.edu/forums/viewtopic.php?id=85177' style='color:#777777'>Having problems?</a>]</small>"; function occurrences(string, substring){ var n=0; var pos=0; while(true){ pos=string.indexOf(substring,pos); if(pos!=-1){ n++; pos+=substring.length;} else{break;} } return(n); }Now it gives a "too many image tags" warning if there are 30+ images, and it bails out of the image processing bit. If you want, you can put a confirm() bypass, but I find this way cleaner.
I don't really see much point in doing this, as any page with more than 30 images still works fine for me. But I don't know, what is it like for others?
Offline
rookwood101 wrote:
Hardmath123 wrote:
rookwood101 wrote:
You should probably put the extra code you added in the if statement, otherwise it will run on any page (in chome, not firefox).
But other than that, great! I tested it and it works perfectly!
I'll debug yours in a sec roijac (lunch)Code:
// ==UserScript== // @name Image Enabler // @namespace rookwood101,Cocolover,LS97,flashgocrazy // @description Enable images, and allow Scratch projects and YouTube videos on forums with BBCode // @include http://scratch.mit.edu/forums/viewtopic.php* // ==/UserScript== if (document.URL.indexOf('http://scratch.mit.edu/forums/viewtopic.php') != -1) { //Set title to fail document.getElementById("brdtitle").innerHTML=document.getElementById("brdtitle").innerHTML+"<span id='imgtagenablerstatus'>Greasemonkey image tag enabler is goofing up. There may be an open tag or invalid image. <small style='color:#777777'>[<a href='http://scratch.mit.edu/forums/viewtopic.php?id=85177' style='color:#777777'>Report this bug!</a>]</small></span>"; //replace img tags var bodyElement = document.getElementsByTagName("body")[0]; var bodyInner = bodyElement.innerHTML; if (occurrences(bodyInner, "[url]")<=30) { var imageurls = new Array(); for (i=0;i<bodyInner.split(/\[img\]/i).length-1;i++) { imageurls[i] = bodyInner.split(/\[img\]/i)[i+1].split(/\[\/img\]/i)[0]; if (imageurls[i].replace(/(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?/i, "") != "") { imageurls[i] = 'http://img94.imageshack.us/img94/6045/invalidimage.png'; } } var addImages = bodyInner; for (i=0;i<imageurls.length;i++) { addImages = addImages.replace(/\[img\](http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?\[\/img\]/i, '<img style="max-width: 510px;" src="' + imageurls[i] + '" />'); } } else { alert("There were too many images to display, so they have been omitted."); } //replace youtube tags var youtubeids = new Array(); for (i=0;i<addImages.split(/\[youtube\]/i).length-1;i++) { youtubeids[i] = addImages.split(/\[youtube\]/i)[i+1].split(/\[\/youtube\]/i)[0]; if (youtubeids[i].replace(/[a-zA-Z0-9\-_]+/, "") != "") { youtubeids[i] = 'dQw4w9WgXcQ'; } } var addYoutube = addImages; for (i=0;i<youtubeids.length;i++) { addYoutube = addYoutube.replace(/\[youtube\]([a-zA-Z0-9\-_]+)\[\/youtube\]/i, '<iframe width="510" height="315" src="http://www.youtube.com/embed/' + youtubeids[i] + '"frameborder="0" allowfullscreen></iframe>'); } //replace project tags var projectpath = new Array(); for (i=0;i<addYoutube.split(/\[scratch=flash\]/i).length-1;i++) { projectpath[i] = addYoutube.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'; } } var addProjects = addYoutube; for (i=0;i<projectpath.length;i++) { addProjects = addProjects.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 = addProjects; } //Set title to success document.getElementById("imgtagenablerstatus").innerHTML="Greasemonkey image tag enabler has completed running. <small style='color:#777777'>[<a href='http://scratch.mit.edu/forums/viewtopic.php?id=85177' style='color:#777777'>Having problems?</a>]</small>"; function occurrences(string, substring){ var n=0; var pos=0; while(true){ pos=string.indexOf(substring,pos); if(pos!=-1){ n++; pos+=substring.length;} else{break;} } return(n); }Now it gives a "too many image tags" warning if there are 30+ images, and it bails out of the image processing bit. If you want, you can put a confirm() bypass, but I find this way cleaner.
I don't really see much point in doing this, as any page with more than 30 images still works fine for me. But I don't know, what is it like for others?
Well, the block library freezes up pretty bad on FireFox 3.1 Mac, I haven't bothered to get GreaseMonkey working of Safari, which I have recorded to be over 15 times faster at string processing.
Offline
muppetds wrote:
for some reason it takes me to the code not the download file
safari browser
doesn't work for safari unless you install stuff. see the op.
Offline
Hardmath123 wrote:
rookwood101 wrote:
Hardmath123 wrote:
Code:
// ==UserScript== // @name Image Enabler // @namespace rookwood101,Cocolover,LS97,flashgocrazy // @description Enable images, and allow Scratch projects and YouTube videos on forums with BBCode // @include http://scratch.mit.edu/forums/viewtopic.php* // ==/UserScript== if (document.URL.indexOf('http://scratch.mit.edu/forums/viewtopic.php') != -1) { //Set title to fail document.getElementById("brdtitle").innerHTML=document.getElementById("brdtitle").innerHTML+"<span id='imgtagenablerstatus'>Greasemonkey image tag enabler is goofing up. There may be an open tag or invalid image. <small style='color:#777777'>[<a href='http://scratch.mit.edu/forums/viewtopic.php?id=85177' style='color:#777777'>Report this bug!</a>]</small></span>"; //replace img tags var bodyElement = document.getElementsByTagName("body")[0]; var bodyInner = bodyElement.innerHTML; if (occurrences(bodyInner, "[url]")<=30) { var imageurls = new Array(); for (i=0;i<bodyInner.split(/\[img\]/i).length-1;i++) { imageurls[i] = bodyInner.split(/\[img\]/i)[i+1].split(/\[\/img\]/i)[0]; if (imageurls[i].replace(/(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?/i, "") != "") { imageurls[i] = 'http://img94.imageshack.us/img94/6045/invalidimage.png'; } } var addImages = bodyInner; for (i=0;i<imageurls.length;i++) { addImages = addImages.replace(/\[img\](http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?\[\/img\]/i, '<img style="max-width: 510px;" src="' + imageurls[i] + '" />'); } } else { alert("There were too many images to display, so they have been omitted."); } //replace youtube tags var youtubeids = new Array(); for (i=0;i<addImages.split(/\[youtube\]/i).length-1;i++) { youtubeids[i] = addImages.split(/\[youtube\]/i)[i+1].split(/\[\/youtube\]/i)[0]; if (youtubeids[i].replace(/[a-zA-Z0-9\-_]+/, "") != "") { youtubeids[i] = 'dQw4w9WgXcQ'; } } var addYoutube = addImages; for (i=0;i<youtubeids.length;i++) { addYoutube = addYoutube.replace(/\[youtube\]([a-zA-Z0-9\-_]+)\[\/youtube\]/i, '<iframe width="510" height="315" src="http://www.youtube.com/embed/' + youtubeids[i] + '"frameborder="0" allowfullscreen></iframe>'); } //replace project tags var projectpath = new Array(); for (i=0;i<addYoutube.split(/\[scratch=flash\]/i).length-1;i++) { projectpath[i] = addYoutube.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'; } } var addProjects = addYoutube; for (i=0;i<projectpath.length;i++) { addProjects = addProjects.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 = addProjects; } //Set title to success document.getElementById("imgtagenablerstatus").innerHTML="Greasemonkey image tag enabler has completed running. <small style='color:#777777'>[<a href='http://scratch.mit.edu/forums/viewtopic.php?id=85177' style='color:#777777'>Having problems?</a>]</small>"; function occurrences(string, substring){ var n=0; var pos=0; while(true){ pos=string.indexOf(substring,pos); if(pos!=-1){ n++; pos+=substring.length;} else{break;} } return(n); }Now it gives a "too many image tags" warning if there are 30+ images, and it bails out of the image processing bit. If you want, you can put a confirm() bypass, but I find this way cleaner.
I don't really see much point in doing this, as any page with more than 30 images still works fine for me. But I don't know, what is it like for others?
Well, the block library freezes up pretty bad on FireFox 3.1 Mac, I haven't bothered to get GreaseMonkey working of Safari, which I have recorded to be over 15 times faster at string processing.
Yeh, when I test it on my mac (mac mini) it freezes up, obviously my pc with an intel i7 2600k is faster
@Roijac - I tried what you were trying to do a slightly different way and still couldn't get it to work. I think this will be quite hard to do, but I'm sure we'll get there eventually.
@everyone can someone try and work on a fix for nXIII's forum blocks?
Offline
rookwood101 wrote:
Hardmath123 wrote:
rookwood101 wrote:
I don't really see much point in doing this, as any page with more than 30 images still works fine for me. But I don't know, what is it like for others?Well, the block library freezes up pretty bad on FireFox 3.1 Mac, I haven't bothered to get GreaseMonkey working of Safari, which I have recorded to be over 15 times faster at string processing.
Yeh, when I test it on my mac (mac mini) it freezes up, obviously my pc with an intel i7 2600k is faster
@Roijac - I tried what you were trying to do a slightly different way and still couldn't get it to work. I think this will be quite hard to do, but I'm sure we'll get there eventually.
@everyone can someone try and work on a fix for nXIII's forum blocks?
I think that would be easy. Just create a tag called [forumblocks] that operates just like the [img] tag, but instead of adding just image HTML, it adds the image HTML+the forum blocks http prefix.
Offline
Hardmath123 wrote:
rookwood101 wrote:
Hardmath123 wrote:
Well, the block library freezes up pretty bad on FireFox 3.1 Mac, I haven't bothered to get GreaseMonkey working of Safari, which I have recorded to be over 15 times faster at string processing.
Yeh, when I test it on my mac (mac mini) it freezes up, obviously my pc with an intel i7 2600k is faster
@Roijac - I tried what you were trying to do a slightly different way and still couldn't get it to work. I think this will be quite hard to do, but I'm sure we'll get there eventually.
@everyone can someone try and work on a fix for nXIII's forum blocks?I think that would be easy. Just create a tag called [forumblocks] that operates just like the [img] tag, but instead of adding just image HTML, it adds the image HTML+the forum blocks http prefix.
I'm not quite sure what you mean by that.
Edit: oh I see, you mean someone would put [forumblocks][commmandblock(hole)][/forumblocks] like that?
Edit: Yeh that sounds pretty doable!
Last edited by rookwood101 (2012-01-03 06:18:49)
Offline
Nexstudent wrote:
It doesn't work. When I click the download link, all it does is bring me to the script
Try then right-clicking and selecting "Save page as..."
Offline
i have a suggestion:
[likebutton](id of a forum topic)[/likebutton]
should make one of rookwood's like buttons!
Offline
joefarebrother wrote:
i have a suggestion:
[likebutton](id of a forum topic)[/likebutton]
should make one of rookwood's like buttons!
Unfortunately, I don't have the time nor the resources to continue developing/hosting the like button system, so linking to it doesn't work, and won't for the foreseeable future.
Offline
gbear605 wrote:
muppetds wrote:
for some reason it takes me to the code not the download file
safari browserdoesn't work for safari unless you install stuff. see the op.
I've installed the stuff
Offline