Because of security restrictions, this can't be done. If such JavaScript existed, a malicious website could easily change your homepage without even asking or requiring you to click a button to do so.
Since you're in a classroom environment, I assume all the computers are managed on a network using some sort of Group Policy. You can use a Group Policy to set settings on computers on a managed network.
Here is how you could do it specifically for Chrome.
https://support.google.com/chrome/a/answer/187202?hl=en
Note In the olden days of Internet Explorer, circa version 5, you could do this with JavaScript, but IE has never been known to be the best when it comes to adhering to good security protocols.