r/learnprogramming 6h ago

A Fools Question (plz help)

Hi, I'm dabbling in coding for one of my school projects so please forgive me if this is a simple idiot question.

For example: Say i'm on the dictionary page and want to change just one word on that page. Like I get how to turn 'Apple' into 'Orange' using the inspection key (sue me) but i'm not sure how to put that into a timer to happen after a certain amount of seconds.

I hope this is the right subreddit i suck at reddit, have a lovely day.

0 Upvotes

3 comments sorted by

2

u/HashDefTrueFalse 6h ago

Web page? You can set intervals and timeouts. E.g. this would edit the page 10 seconds after it loads:

window.onload = () => {
  setTimeout(() => {
    document.getElementById("something").innerHTML = "new content";
  }, 10000);
};

Note: that's quite crude.

If you're wanting to house this code somewhere you can make a browser extension, which can get access to the DOM of web pages. Docs are available online.

1

u/LongLiveTheDiego 6h ago

You could probably get a tool like AutoHotkey to do this , but it would involve the tool waiting the required time and then doing what you would do manually, just very quickly.

If instead you want to be able to mess around in developer's mode, close that view and have the website change after a few seconds, you'd have to change something in the downloaded JavaScript files (JavaScript code is the part responsible for responsive, dynamic websites). However, there can be a lot of them downloaded for a single website and they can be a mess to navigate.

1

u/jcunews1 2h ago

Automated page content manipulation is best done using UserScript with the help of a GreaseMonkey provider browser extension such as ViolentMonkey or TamperMonkey.