This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2011-12-31 12:16:00

flashgocrazy
Scratcher
Registered: 2011-01-12
Posts: 500+

Userscript help!

Hi,
I have this userscript:

Code:

// ==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  smile


◕‿◕

Offline

 

#2 2011-12-31 12:51:41

flashgocrazy
Scratcher
Registered: 2011-01-12
Posts: 500+

Re: Userscript help!

bump


◕‿◕

Offline

 

#3 2011-12-31 13:00:38

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: Userscript help!

just duplicate the code of one of the 'var addXX' lines, and always change the last line to body......innerHTML = addXX[variableOfLineBeforeThat]

Offline

 

#4 2011-12-31 13:02:07

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: Userscript help!

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

 

#5 2011-12-31 13:11:22

GirWaffles64
Scratcher
Registered: 2009-08-09
Posts: 1000+

Re: Userscript help!

I was looking for a soundcloud embed.


hey kiddoes i'm back

Offline

 

#6 2011-12-31 13:12:28

flashgocrazy
Scratcher
Registered: 2011-01-12
Posts: 500+

Re: Userscript help!

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

 

#7 2011-12-31 13:33:39

flashgocrazy
Scratcher
Registered: 2011-01-12
Posts: 500+

Re: Userscript help!

test [+1]

Last edited by flashgocrazy (2011-12-31 18:39:05)


◕‿◕

Offline

 

#8 2011-12-31 13:36:49

gbear605
Scratcher
Registered: 2008-03-06
Posts: 1000+

Re: Userscript help!

for example:
I added an [h1] thing.  It'll make text the size of h1 in HTML.

Code:

// ==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)


Yeah, I'm mostly inactive.  I check in once in a while though.  If you want to contact me, I have a contact form at my website, http://escratch.org

Offline

 

#9 2011-12-31 13:37:32

flashgocrazy
Scratcher
Registered: 2011-01-12
Posts: 500+

Re: Userscript help!

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

 

#10 2011-12-31 13:39:15

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: Userscript help!

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

 

#11 2011-12-31 13:40:32

flashgocrazy
Scratcher
Registered: 2011-01-12
Posts: 500+

Re: Userscript help!

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 code

You have to do \" in the quotes, because it ended the string.

Code for it?  roll

Last edited by flashgocrazy (2011-12-31 13:40:55)


◕‿◕

Offline

 

#12 2011-12-31 13:42:16

flashgocrazy
Scratcher
Registered: 2011-01-12
Posts: 500+

Re: Userscript help!

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 code

You have to do \" in the quotes, because it ended the string.

Ii dont get it.  what \?


◕‿◕

Offline

 

#13 2011-12-31 13:47:15

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: Userscript help!

flashgocrazy wrote:

scimonster wrote:

flashgocrazy wrote:


its not working
here is the code

You have to do \" in the quotes, because it ended the string.

Ii dont get it.  what \?

Try this.

Code:

// ==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

 

#14 2011-12-31 14:00:11

flashgocrazy
Scratcher
Registered: 2011-01-12
Posts: 500+

Re: Userscript help!

Dis is epik! I can use the java player here! :3


◕‿◕

Offline

 

#15 2011-12-31 15:30:19

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: Userscript help!

Nice! So can I use scimon's code above as a userscript in Chrome? Or did you add anythign else?

Offline

 

#16 2011-12-31 16:22:42

flashgocrazy
Scratcher
Registered: 2011-01-12
Posts: 500+

Re: Userscript help!

added java player


◕‿◕

Offline

 

#17 2011-12-31 17:40:50

rookwood101
Scratcher
Registered: 2011-07-29
Posts: 500+

Re: Userscript help!

In terms of adding like buttons, you could add google +1 buttons and/or facebook like buttons on a per post basis quite easily.


http://i.imgur.com/zeIZW.png

Offline

 

#18 2011-12-31 17:42:38

ProgrammingFreak
Scratcher
Registered: 2010-09-04
Posts: 1000+

Re: Userscript help!

Hey, kyle? Could you not have a youtube video in your signature? It makes things laggy.

Offline

 

#19 2011-12-31 17:53:19

flashgocrazy
Scratcher
Registered: 2011-01-12
Posts: 500+

Re: Userscript help!

ProgrammingFreak wrote:

Hey, kyle? Could you not have a youtube video in your signature? It makes things laggy.

who is kyle?


◕‿◕

Offline

 

#20 2011-12-31 18:04:45

ProgrammingFreak
Scratcher
Registered: 2010-09-04
Posts: 1000+

Re: Userscript help!

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

 

#21 2011-12-31 18:28:48

flashgocrazy
Scratcher
Registered: 2011-01-12
Posts: 500+

Re: Userscript help!

[swfembed]http://www.w3schools.com/flash/helloworld.swf[/swfembed] test...


◕‿◕

Offline

 

#22 2012-01-01 04:16:53

nathanprocks
Scratcher
Registered: 2011-04-14
Posts: 1000+

Re: Userscript help!

i have an idea... iframes!... good for forms, etc.

Last edited by nathanprocks (2012-01-01 04:17:10)


http://carrot.cassiedragonandfriends.org/Scratch_Signature/randomsig.php
http://trinary.site40.net/images/scratchrank.php?username=nathanprocks&amp;display=small

Offline

 

#23 2012-01-01 08:18:00

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: Userscript help!

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.  tongue

Last edited by scimonster (2012-01-01 08:18:16)

Offline

 

Board footer