Ho do you make a user script that changes the HTML on a website?
Offline
That's quite a vague question. What are you trying to do?
Offline
// ==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>';
Offline
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.
Offline
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)
Offline
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)
Offline
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)
Offline
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:
// @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!
Offline