roijac wrote:
you may want to do something like <img src=image.jpg width=whatever> because it doesn't resize anymore
how about
style="max-width: whatever;"
Offline
It seems to me like you're always forgetting the closing / for HTML elements... I only had a quick look at the code, but the JS looks fine (except for some very big lack of optimization)
Offline
LS97 wrote:
It seems to me like you're always forgetting the closing / for HTML elements... I only had a quick look at the code, but the JS looks fine (except for some very big lack of optimization)
how do I fix it?
Offline
flashgocrazy wrote:
LS97 wrote:
It seems to me like you're always forgetting the closing / for HTML elements... I only had a quick look at the code, but the JS looks fine (except for some very big lack of optimization)
how do I fix it?
Here, let me do it for ya... watch this thread for an edit in 3 minutes!
EDIT
done
// ==UserScript== // @name enable images on scratch forum and have bbcode // @namespace flash // @description enable images on scratch forum and have more bbcode // @include http://scratch.mit.edu/forums/* // ==/UserScript== var bodyInner = document.body.innerHTML; // Images var replaceOne = bodyInner.replace('[img]', "<img src='"); var replaceTwo = replaceOne.replace('[/img]', "' />"); document.body.innerHTML = replaceTwo; // Scratch Projects var replaceOne = bodyInner.replace('[scratch=flash]', "<embed src=http://scratch.mit.edu/static/misc/PlayerOnly.swf?project=http://'"); var replaceTwo = replaceOne.replace('[/scratch=flash]', "' />"); document.body.innerHTML = replaceTwo; // Youtube var replaceOne = bodyInner.replace('[youtube]', "<embed src=www.youtube.com/embed/'"); var replaceTwo = replaceOne.replace('[/youtube]', " /'>"); document.body.innerHTML = replaceTwo;
Last edited by LS97 (2011-12-30 09:32:15)
Offline
[youtube]JTuXPUP06H0[/youtube] testing
Offline
worky?
Offline
@ls97
// ==UserScript== // @name enable images on scratch forum // @namespace rookwood101 // @description enable images on scratch forum // @include http://scratch.mit.edu/forums/viewtopic.php* // ==/UserScript== if (document.URL.indexOf('http://scratch.mit.edu/forums/viewtopic.php') != -1) { var bodyElement = document.getElementsByTagName("body")[0]; var bodyInner = bodyElement.innerHTML; for (i=0;i<bodyInner.split(/\[img\]/i).length-1;i++) { var replaceOne = bodyInner.replace(/\[img\]/ig, '<img src="'); var replaceTwo = replaceOne.replace(/\[\/img\]/ig, '" style="max-width: 100"/>'); document.getElementsByTagName("body")[0].innerHTML = replaceTwo; } }
what's wrong?
test:
Last edited by roijac (2011-12-30 09:45:32)
Offline
LS97 wrote:
worky?
almost....
By the way have you checked out this post? I can do a review on your mod, bingo
Offline
@roijac:
Why is that so complicated? Let me try understanding it and cutting it down a bit...
Offline
roijac, try that:
// ==UserScript== // @name enable images on scratch forum // @namespace rookwood101 // @description enable images on scratch forum // @include http://scratch.mit.edu/forums/viewtopic.php* // ==/UserScript== var bodyInner = document.body.innerHTML; for (i=0; i<bodyInner.split(/\[img\]/i).length-1; i++) { var replaceOne = bodyInner.replace(/\[img\]/i, '<img src="'); var replaceTwo = replaceOne.replace(/\[\/img\]/i, '" style="max-width: 300"/>'); document.body.innerHTML = replaceTwo; }
Offline
LS97 wrote:
worky?
Its still not working!
You can check it here
Offline
@ls97, your code doesn't work, it gets messed up with words like [img]
btw, did you know that writing [img] is messing smilies up with my script?
[img]
Last edited by roijac (2011-12-30 09:58:33)
Offline
LS97 wrote:
roijac, try that:
Code:
// ==UserScript== // @name enable images on scratch forum // @namespace rookwood101 // @description enable images on scratch forum // @include http://scratch.mit.edu/forums/viewtopic.php* // ==/UserScript== var bodyInner = document.body.innerHTML; for (i=0; i<bodyInner.split(/\[img\]/i).length-1; i++) { var replaceOne = bodyInner.replace(/\[img\]/i, '<img src="'); var replaceTwo = replaceOne.replace(/\[\/img\]/i, '" style="max-width: 300"/>'); document.body.innerHTML = replaceTwo; }
for some reason only the first image on a page works with any of the scripts and chrome, any help?
Offline
@flash, see if this works:
// ==UserScript== // @name Extra BBCode for Scratch Fora // @namespace flash and LS97 // @description Enable images on the Scratch forums and feature more BB-Code! // @include http://scratch.mit.edu/forums/viewtopic.php* // ==/UserScript== var bodyInner = document.body.innerHTML; // Images document.body.innerHTML = bodyInner.replace(/\[img\]/ig, "<img src='").replace(/\[\/img\]/ig, "' />"); // Scratch Projects document.body.innerHTML = bodyInner.replace(/\[scratch=flash\]/, "<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/'").replace(/\[\/scratch=flash\]/, "'"></object>"); // Youtube document.body.innerHTML = bodyInner.replace(/[\youtube\]/, "<iframe width="420" height="315" src="http://www.youtube.com/embed/'").replace(/\[\/youtube\]/, " '" frameborder="0" allowfullscreen></iframe>");
Offline
Something really stupid is probably missing from my scripts...
But with only notepad to write with on this computer, the error could be anywhere...
Offline
LS97 wrote:
@flash, see if this works:
Code:
// ==UserScript== // @name Extra BBCode for Scratch Fora // @namespace flash and LS97 // @description Enable images on the Scratch forums and feature more BB-Code! // @include http://scratch.mit.edu/forums/viewtopic.php* // ==/UserScript== var bodyInner = document.body.innerHTML; // Images document.body.innerHTML = bodyInner.replace(/\[img\]/ig, "<img src='").replace(/\[\/img\]/ig, "' />"); // Scratch Projects document.body.innerHTML = bodyInner.replace(/\[scratch=flash\]/, "<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/'").replace(/\[\/scratch=flash\]/, "'"></object>"); // Youtube document.body.innerHTML = bodyInner.replace(/[\youtube\]/, "<iframe width="420" height="315" src="http://www.youtube.com/embed/'").replace(/\[\/youtube\]/, " '" frameborder="0" allowfullscreen></iframe>");
nope.only one image per page, and no youtube player. Also, it happens with every script that I have downloaded for this.
Offline
LS97 wrote:
@flash, see if this works:
Code:
// ==UserScript== // @name Extra BBCode for Scratch Fora // @namespace flash and LS97 // @description Enable images on the Scratch forums and feature more BB-Code! // @include http://scratch.mit.edu/forums/viewtopic.php* // ==/UserScript== var bodyInner = document.body.innerHTML; // Images document.body.innerHTML = bodyInner.replace(/\[img\]/ig, "<img src='").replace(/\[\/img\]/ig, "' />"); // Scratch Projects document.body.innerHTML = bodyInner.replace(/\[scratch=flash\]/, "<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/'").replace(/\[\/scratch=flash\]/, "'"></object>"); // Youtube document.body.innerHTML = bodyInner.replace(/[\youtube\]/, "<iframe width="420" height="315" src="http://www.youtube.com/embed/'").replace(/\[\/youtube\]/, " '" frameborder="0" allowfullscreen></iframe>");
testing image
testing scratch project
[scratch=flash]Mr-Negitive/1772157.sb?version=1[/scratch=flash]
testing youtube...
[youtube]JTuXPUP06H0[/youtube]
Last edited by flashgocrazy (2011-12-30 10:10:30)
Offline
It's really weird, because I told it to go through all images (global tag), maybe it didn't listen...
Offline
gbear605 wrote:
LS97 wrote:
@flash, see if this works:
Code:
// ==UserScript== // @name Extra BBCode for Scratch Fora // @namespace flash and LS97 // @description Enable images on the Scratch forums and feature more BB-Code! // @include http://scratch.mit.edu/forums/viewtopic.php* // ==/UserScript== var bodyInner = document.body.innerHTML; // Images document.body.innerHTML = bodyInner.replace(/\[img\]/ig, "<img src='").replace(/\[\/img\]/ig, "' />"); // Scratch Projects document.body.innerHTML = bodyInner.replace(/\[scratch=flash\]/, "<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/'").replace(/\[\/scratch=flash\]/, "'"></object>"); // Youtube document.body.innerHTML = bodyInner.replace(/[\youtube\]/, "<iframe width="420" height="315" src="http://www.youtube.com/embed/'").replace(/\[\/youtube\]/, " '" frameborder="0" allowfullscreen></iframe>");nope.only one image per page, and no youtube player. Also, it happens with every script that I have downloaded for this.
If you download the newer one, it should work. It does for me.
I'll post a screenshot of the blocklibrary back in action in chrome:
I was looking at my code compared to your code, and I can't understand why mine needs the for loop, AND the /g regex code because in theory it shouldn't need one with the other.
Last edited by rookwood101 (2011-12-30 11:40:49)
Offline
// ==UserScript== // @name enable images on scratch forum // @namespace rookwood101 // @description enable images on scratch forum // @include http://scratch.mit.edu/forums/viewtopic.php* // ==/UserScript== if (document.URL.indexOf('http://scratch.mit.edu/forums/viewtopic.php') != -1) { var bodyElement = document.getElementsByTagName("body")[0]; var bodyInner = bodyElement.innerHTML; var addImages = bodyInner.replace(/\[img\]/ig, '<img src="').replace(/\[\/img\]/ig, '">'); var addYoutube = addImages.replace(/\[youtube\]/ig, '<iframe width="420" height="315" src="http://www.youtube.com/embed/').replace(/\[\/youtube\]/ig, '"frameborder="0" allowfullscreen></iframe>'); var addProjects = addYoutube.replace(/\[scratch=flash\]/ig, '<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/').replace(/\[\/scratch\]/ig, '.sb?version=1"></object>'); document.getElementsByTagName("body")[0].innerHTML = addProjects; }
Done! (haven't added scratch projects yet though) - Edit: have now
The reason why your code for scratch projects doesn't work is because you have the url wrong.
Using this script will ruin this page of the topic as the code posted on here interferes with the script. I have set up a post here to test it though.
Last edited by rookwood101 (2011-12-30 12:21:38)
Offline
Erm, you might want to add something that makes stuff not show up in code boxes...
It's breaking this page
Offline
Yes, I noticed that - easier said than done though.
Offline
rookwood101 wrote:
[scratch=flash]rookwood101/1951425[/scratch]
I removed this since I had to disable the plugin to see this because I broke this page XD
Last edited by cocolover76 (2011-12-30 14:14:29)
Offline
testing[url=javascript:var bodyElement = document.getElementsByTagName("body")[0]; var bodyInner = bodyElement.innerHTML; var replaceOne = bodyInner.replace("[img]", "<img src='"); var replaceTwo = replaceOne.replace("[/img]", "'>"); document.write("<h3>Optimized by a script by Coco and Bobbybee! </h3>" + replaceTwo);]test[/url]
Offline