IceGod
IceGod

Reputation: 61

Change a specific link from text with Greasemonkey

I'm very new to Greasemonkey, so please be understanding. Here is my problem :

I'm currently doing some changes to a web game to make it more usable on a laptop to have a bigger fullscreen without getting rid of any functions. I've basically done everything by myself, but now there's something that I'm not able to do. I want to change the URL (clickable through some text) to my specific URL. I've figured that I can change the href value from the previous url (/maps) to my url (/search). But I'm not able to implement it into my script, as it doesn't work the same as the previous things I changed on the website.

Can anyone help? I think this is relatively easy, I just can't find anything on it, maybe I'm googling the wrong terms.

Upvotes: 0

Views: 175

Answers (1)

Pinkie Pie
Pinkie Pie

Reputation: 728

Based on the additional information in the comments, this should do

document.querySelector("a[href='/maps']").href = "/search";

while there's only one of these elements at the time of this answer. If that changes, you can use querySelectorAll instead and iterate the results then.

Upvotes: 1

Related Questions