JavaScript switch function for what the URL contains (bookmarklet)

30 Views Asked by At

I want to make a bookmarklet that will do something based on what website you are on. How could I detect this and make use of it for a switch function?

It would need to work for all pages inside of the site (like example.com/play and /select, for example). As an additional question, how can you make one case allow 2 things? Can you just use logical or? Would the below be acceptable?

switch(var) {
case "a" || "b":
alert("a or b");
break;
case "c":
alert("c");
break;
default:
alert("don't know");
break;

Thank you in advance.

0

There are 0 best solutions below