Hi,
I have this userscript:
// ==UserScript==
// @name enable images on scratch forum and more!
// @namespace rookwood101,Cocolover,LS97,flashgocrazy
// @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) {
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;
}and I was wondering how do you add more bbcode to it.
Thanks,
Flash
Offline
just duplicate the code of one of the 'var addXX' lines, and always change the last line to body......innerHTML = addXX[variableOfLineBeforeThat]
Offline
Also, if I may suggest some code to add,
- Current time in your country (just JS time)
- Post liker
- Font size
Last edited by LS97 (2011-12-31 13:02:24)
Offline
I was looking for a soundcloud embed.
Offline
LS97 wrote:
just duplicate the code of one of the 'var addXX' lines, and always change the last line to body......innerHTML = addXX[variableOfLineBeforeThat]
do you have an examle of code with annother bbcode added to it
Offline
test [+1]
Last edited by flashgocrazy (2011-12-31 18:39:05)
Offline
for example:
I added an [h1] thing. It'll make text the size of h1 in HTML.
// ==UserScript==
// @name enable images on scratch forum and more!
// @namespace rookwood101,Cocolover,LS97,flashgocrazy
// @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) {
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;
var addH1 = addProjects.replace(/\[h1\]/ig, '<h1>"').replace(/\[\/img\]/ig, '"</h1>');
}Last edited by gbear605 (2011-12-31 13:37:05)
Offline
LS97 wrote:
just duplicate the code of one of the 'var addXX' lines, and always change the last line to body......innerHTML = addXX[variableOfLineBeforeThat]
its not working
here is the code
Last edited by flashgocrazy (2011-12-31 13:38:26)
Offline
flashgocrazy wrote:
LS97 wrote:
just duplicate the code of one of the 'var addXX' lines, and always change the last line to body......innerHTML = addXX[variableOfLineBeforeThat]
its not working
here is the code
You have to do \" in the quotes, because it ended the string.
Offline
scimonster wrote:
flashgocrazy wrote:
LS97 wrote:
just duplicate the code of one of the 'var addXX' lines, and always change the last line to body......innerHTML = addXX[variableOfLineBeforeThat]
its not working
here is the codeYou have to do \" in the quotes, because it ended the string.
Code for it?
Last edited by flashgocrazy (2011-12-31 13:40:55)
Offline
scimonster wrote:
flashgocrazy wrote:
LS97 wrote:
just duplicate the code of one of the 'var addXX' lines, and always change the last line to body......innerHTML = addXX[variableOfLineBeforeThat]
its not working
here is the codeYou have to do \" in the quotes, because it ended the string.
Ii dont get it. what \?
Offline
flashgocrazy wrote:
scimonster wrote:
flashgocrazy wrote:
its not working
here is the codeYou have to do \" in the quotes, because it ended the string.
Ii dont get it. what \?
Try this.
// ==UserScript==
// @name enable images on scratch forum and more Including java!
// @namespace rookwood101,Cocolover,LS97,flashgocrazy
// @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) {
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 addFlash = 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>');
var addJava = addFlash.replace(/\[scratch=java\]/ig, '<applet id="ProjectApplet" style="display:block" code="ScratchApplet" codebase="http://scratch.mit.edu/static/misc" archive="ScratchApplet.jar" height="387" width="482"><param name="project" value="../../static/projects/').replace(/\[\/scratchjava\]/ig, '.sb"></applet>');
document.getElementsByTagName("body")[0].innerHTML = addJava;
}Offline
Dis is epik! I can use the java player here! :3
Offline
Nice! So can I use scimon's code above as a userscript in Chrome? Or did you add anythign else?
Offline
added java player
Offline
In terms of adding like buttons, you could add google +1 buttons and/or facebook like buttons on a per post basis quite easily.
Offline
Hey, kyle? Could you not have a youtube video in your signature? It makes things laggy.
Offline
ProgrammingFreak wrote:
Hey, kyle? Could you not have a youtube video in your signature? It makes things laggy.
who is kyle?
Offline
flashgocrazy wrote:
ProgrammingFreak wrote:
Hey, kyle? Could you not have a youtube video in your signature? It makes things laggy.
who is kyle?
Oh sorry. I thought you were flamekyle for some reason. I was talking to you though.
Offline
[swfembed]http://www.w3schools.com/flash/helloworld.swf[/swfembed] test...
Offline
i have an idea... iframes!... good for forms, etc.
Last edited by nathanprocks (2012-01-01 04:17:10)
Offline
LS97 wrote:
Nice! So can I use sci's code above as a userscript in Chrome? Or did you add anything else?
You can use it, and if you want, you can add your own stuff too.
Last edited by scimonster (2012-01-01 08:18:16)
Offline