I'm trying to make a bookmarklet that changes every link on a page to "https://www.youtube.com/watch?v=dQw4w9WgXcQ" and I've gotten this far:
javascript:var jq=document.createElement("script");jq.setAttribute("src","https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js");document.body.appendChild(jq);$("a").attr("href","https://www.youtube.com/watch?v=dQw4w9WgXcQ%22);
Here's it formatted if you need it
var jq = document.createElement("script");
jq.setAttribute("src", "https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js");
document.body.appendChild(jq); //install jquery because it's the only html editing language i know
$("a").attr("href", "https://www.youtube.com/watch?v=dQw4w9WgXcQ%22);//replace all links
I do know some sites won't let you inject jQuery, but on ones that you can, the html editor shows that the href of the "a" tag has changed but won't go to the new link. This mostly happens with "/subpage" links.
EDIT:
I managed to do it without jquery:
javascript:var a = document.querySelectorAll("a");a.forEach(function(a){a.href = "https://www.youtube.com/watch?v=dQw4w9WgXcQ%22;});alert(%22done.%22);
a.forEach(function(a){
a.href = "https://www.youtube.com/watch?v=dQw4w9WgXcQ";
});
alert("done.");```
The console still shows that the link has changed, but still brings me to the link that it was previously.