简体   繁体   中英

How can I run my console JS codes everytime?

My college online education website has a dark mode but my choice is not memorized. And they hadn't changed that since it started. I can change that via Chrome console by themebase.replace("light", "dark") but I want it run when I started the website every time.

I tried to create a file named yildiz.html

 <script> window.location.href="https://online.yildiz.edu.tr/"; alert("test"); themebase.replace("light", "dark"); </script>

As you can imagine, the rest of the code doesn't run when href changes.

Thank you

You can use Tampermonkey to run your script continuously. Otherwise, your code will not work if you change the URL or refresh it. Install the extension and create a new script. Change @match as follows to match your URL and all of its pages -

// @match        https://online.yildiz.edu.tr/*

Now write your script where you are told to write your own code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM