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

#1 2013-04-04 14:20:16

machinespray
Scratcher
Registered: 2012-05-09
Posts: 93

Userscript

Ho do you make a user script that changes the HTML on a website?


I am made a mod for Scratch. If you have any ideas for the mod please post it on this forum page.http://scratch.mit.edu/forums/viewtopic.php?id=108265http://internetometer.com/image/38591.png
I am http://blocks.scratchr.org/API.php?action=onlineStatus&type=text&user=machinespray

Offline

 

#2 2013-04-04 15:26:46

mythbusteranimator
Scratcher
Registered: 2012-02-28
Posts: 1000+

Re: Userscript

No idea.


http://www.foxtrot.com/comics/2012-04-01-fdb37077.gif
clicky

Offline

 

#3 2013-04-04 16:14:55

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: Userscript

That's quite a vague question. What are you trying to do?


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#4 2013-04-04 22:09:39

GeonoTRON2000
Scratcher
Registered: 2009-12-24
Posts: 1000+

Re: Userscript

Code:

// ==UserScript==
// @name           ExampleScript
// @description    Thingy that does stuff.
// @version        1.0
// @namespace      http://userscripts.mysite.com/
// @include        http://*.mysite.com/*
// ==/UserScript==

var body = document.getElementsByTagName("body")[0];
body.innerHTML = '<html><!-- Your stuff here! --></html>';

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

Offline

 

#5 2013-04-05 08:00:45

machinespray
Scratcher
Registered: 2012-05-09
Posts: 93

Re: Userscript

GeonoTRON2000 wrote:

Code:

// ==UserScript==
// @name           ExampleScript
// @description    Thingy that does stuff.
// @version        1.0
// @namespace      http://userscripts.mysite.com/
// @include        http://*.mysite.com/*
// ==/UserScript==

var body = document.getElementsByTagName("body")[0];
body.innerHTML = '<html><!-- Your stuff here! --></html>';

It still does not work.


I am made a mod for Scratch. If you have any ideas for the mod please post it on this forum page.http://scratch.mit.edu/forums/viewtopic.php?id=108265http://internetometer.com/image/38591.png
I am http://blocks.scratchr.org/API.php?action=onlineStatus&amp;type=text&amp;user=machinespray

Offline

 

#6 2013-04-05 08:08:14

machinespray
Scratcher
Registered: 2012-05-09
Posts: 93

Re: Userscript

blob8108 wrote:

That's quite a vague question. What are you trying to do?

I am trying to make a userscript that replaces part to the school website with:

What I would like to change
Thought for the week:  We teach kids pointless things. That is our goal, to waste their time and money. We waste their money by doing overpriced fund raisers. We waste their time by boring them. We don`t just do it because we are paid for it we do it because it  is our passion.           -Connor PTA

EDIT: No, I am not a trouble-maker I just think that this is funny.

Last edited by machinespray (2013-04-05 08:09:30)


I am made a mod for Scratch. If you have any ideas for the mod please post it on this forum page.http://scratch.mit.edu/forums/viewtopic.php?id=108265http://internetometer.com/image/38591.png
I am http://blocks.scratchr.org/API.php?action=onlineStatus&amp;type=text&amp;user=machinespray

Offline

 

#7 2013-04-05 09:35:27

mythbusteranimator
Scratcher
Registered: 2012-02-28
Posts: 1000+

Re: Userscript

machinespray wrote:

GeonoTRON2000 wrote:

Code:

// ==UserScript==
// @name           ExampleScript
// @description    Thingy that does stuff.
// @version        1.0
// @namespace      http://userscripts.mysite.com/
// @include        http://*.mysite.com/*
// ==/UserScript==

var body = document.getElementsByTagName("body")[0];
body.innerHTML = '<html><!-- Your stuff here! --></html>';

It still does not work.

Well, did you edit it to what you need to do?

Last edited by mythbusteranimator (2013-04-05 09:35:38)


http://www.foxtrot.com/comics/2012-04-01-fdb37077.gif
clicky

Offline

 

#8 2013-04-06 12:32:23

machinespray
Scratcher
Registered: 2012-05-09
Posts: 93

Re: Userscript

mythbusteranimator wrote:

machinespray wrote:

GeonoTRON2000 wrote:

Code:

// ==UserScript==
// @name           ExampleScript
// @description    Thingy that does stuff.
// @version        1.0
// @namespace      http://userscripts.mysite.com/
// @include        http://*.mysite.com/*
// ==/UserScript==

var body = document.getElementsByTagName("body")[0];
body.innerHTML = '<html><!-- Your stuff here! --></html>';

It still does not work.

Well, did you edit it to what you need to do?

yes
I do not want to edit the whole body I just want to change a single paragraph.

Last edited by machinespray (2013-04-06 12:32:59)


I am made a mod for Scratch. If you have any ideas for the mod please post it on this forum page.http://scratch.mit.edu/forums/viewtopic.php?id=108265http://internetometer.com/image/38591.png
I am http://blocks.scratchr.org/API.php?action=onlineStatus&amp;type=text&amp;user=machinespray

Offline

 

#9 2013-04-07 13:59:43

joefarebrother
Scratcher
Registered: 2011-04-08
Posts: 1000+

Re: Userscript

You write normal javascript code to do it, then you save it "filename.user.js", replacing filename with the actual file name. The "user" bit is important!
(optional:) Add this at the start:

Code:

// @name             The name of your userscript
// @description    A brief description of your userscript
// @version          1.0 - increment when you update it
// @namespace  a url to your site
// @include          a url to any site you want the userscript to affect, use * as a wildcard, you can have multiple @include clauses to affect multiple sites.
// @exclude         a url to any site you do not want your userscript to affect if it would otherwise be included by an @include clause. You can have multiple @exclude clauses




The actual javascript code goes here

Then install it onto your browser!


My latest project is called http://tinyurl.com/d2m8hne! It has http://tinyurl.com/d395ygk views, http://tinyurl.com/cnasmt7 love-its, and http://tinyurl.com/bwjy8xs comments.
http://tinyurl.com/756anbk   http://tinyurl.com/iplaychess

Offline

 

Board footer