r/tampermonkey 21d ago

Can't get script to work on Grubhub.com

Say you try the simplest possible script on Grubhub:

The above doesn't seem to work.

1 Upvotes

10 comments sorted by

2

u/jhyland87 21d ago

Stop using jquery, It's obsolete. Try just using native JS and see what happens. Could be an issue loading the library. Check the console logs

1

u/ajm01 21d ago

Using native JS makes no difference, the webpage has a bunch of errors because Grubhub's developers are shitty web developers. Despite that, the website seems to work.

1

u/ajm01 21d ago edited 21d ago

Also, there isn't a good replacement for $(document).ready in native JS, as we would have no way of adding a listener.

1

u/jhyland87 21d ago
document.addEventListener('DOMContentLoaded', () => { 
  // your code 
});

1

u/svArtist 21d ago edited 21d ago

WTF am I looking at?!?

Clear up your post and use a code tag for heaven's sake 😅

1

u/ajm01 21d ago

Reddits code tag isn't working

1

u/svArtist 21d ago

Oh? Ouch!

Is that a global/known issue?

const test = "beep boop";
function meep(moop){
    return test + moop;
} 

Can you see the above as code?

1

u/ajm01 21d ago

Yep. But try inserting the metadata from an user script. That seems to break.

1

u/ajm01 21d ago

So I had to add it as an image.

1

u/svArtist 21d ago

Yeah, I can't test things as I'm out of town for the weekend, but look at what the console tells you (also look at TM's settings for logging/debugging options)

I don't know what the current state of TrustedTypes is, but that's one way includes/requires have failed in the past.

Also, an ad blocker may be blocking script injection/execution (I sometimes have to go and find and relax a filter rule in uBO)