How to? a custom link on a webpage that I don't control (Firefox)
July 2, 2022 9:33 AM
I would like to add /inject a custom link into a webpage that I don't control (think a specific subreddit or Facebook group). I have specific tasks related to those forums/social websites that are on another website, so I would like a link to show up (on a banner, footer, floating) somewhere on the webpage.
I am on firefox, but would be open to using other browsers for this. It can't be domain specific, for example I have different links that need to show up on forum A and forum B, but those forums are both on the same domain - so it needs to match URLs.
I've already tried a few things
Hypothesis - but that requires basically loading another website - and doesn't show up on or in the actual loading page itself.
Custom Host Banner Extension on FF - shows up ok, but it doesn't load links or allow URL matching - only domain matching.
Page Edit (extension on FF) - edits to the webpage aren't persistent.
I am on firefox, but would be open to using other browsers for this. It can't be domain specific, for example I have different links that need to show up on forum A and forum B, but those forums are both on the same domain - so it needs to match URLs.
I've already tried a few things
Hypothesis - but that requires basically loading another website - and doesn't show up on or in the actual loading page itself.
Custom Host Banner Extension on FF - shows up ok, but it doesn't load links or allow URL matching - only domain matching.
Page Edit (extension on FF) - edits to the webpage aren't persistent.
Are you comfortable with JavaScript at all? TamperMonkey will let you inject your own JavaScript into any website, with URL filters so you see the right things on the right pages.
Not really "comfortable", but I'm not afraid of experimenting. I briefly looked at TamperMonkey, but couldn't find any example scripts that matched my use case. Maybe I just don't know the exact terminology to look for it. Do you know of any examples that work close to how I want?
posted by Brent Parker at 9:44 AM on July 2, 2022
Not really "comfortable", but I'm not afraid of experimenting. I briefly looked at TamperMonkey, but couldn't find any example scripts that matched my use case. Maybe I just don't know the exact terminology to look for it. Do you know of any examples that work close to how I want?
posted by Brent Parker at 9:44 AM on July 2, 2022
I'm thinking a JavaScript bookmarklet (or a folder of them) might do the trick. My scenario is that you want to report a page to a certain authority but each site has a different authority and you want the link to the authority to always be there on the page. That's hard because you would have to inject HTML into the right place, but the HTML of the site might change out from under your feet and your thing doesn't work anymore.
A bookmarklet (or a few) on the other hand doesn't try to modify the HTML of the visible page, it's just something up on the bookmarks bar (or in a bookmark folder) that is always there and you just click on it.
If you can JavaScript, it is the same click on this to do that without trying to modify the HTML of the site.
posted by zengargoyle at 11:36 AM on July 2, 2022
A bookmarklet (or a few) on the other hand doesn't try to modify the HTML of the visible page, it's just something up on the bookmarks bar (or in a bookmark folder) that is always there and you just click on it.
If you can JavaScript, it is the same click on this to do that without trying to modify the HTML of the site.
javascript:(function(){ window.open('http://deslide.clusterfake.net?o=html_table&u='+encodeURIComponent(location.href)); })()Is an old forgotten one that sends the current page to the deslide service (gah, slideshows). But you could make one for each site, or you could make one that works for all the sites. If you're going to have to learn some JavaScript anyways.... much easier to make bookmarklet(s) that don't have to mess with the uncontrollable HTML of the displayed page.
posted by zengargoyle at 11:36 AM on July 2, 2022
I found the Userscript "Share to Telegram (floating bubble)" and loaded it into TamperMonkey. It almost works. I can get it to match an initial path on a domain, but I can't get it to match the next part of the path. I've tried:
@match https://domain.us/forums/forumA
and
@match https://domain.us/forums/forumA/
and
@match https://domain.us/forums/forumA/*
will match nothing
@match https://domain.us/forums/forumA*
will match both https://domain.us/forums/forumA and https://domain.us/forums/forumB, but I need different links for each domain.
The documentation for @match doesn't seem to have very many examples for path, but I wonder if TamperMonkey's implementation is broken because @match https://domain.us/forums/for*umA also doesn't match and it seems like it should per the documentation.
posted by Brent Parker at 12:20 PM on July 2, 2022
@match https://domain.us/forums/forumA
and
@match https://domain.us/forums/forumA/
and
@match https://domain.us/forums/forumA/*
will match nothing
@match https://domain.us/forums/forumA*
will match both https://domain.us/forums/forumA and https://domain.us/forums/forumB, but I need different links for each domain.
The documentation for @match doesn't seem to have very many examples for path, but I wonder if TamperMonkey's implementation is broken because @match https://domain.us/forums/for*umA also doesn't match and it seems like it should per the documentation.
posted by Brent Parker at 12:20 PM on July 2, 2022
More or less equal to the @include tag. @include /^https:\/\/www\.tampermonkey\.net\/.*$/ //A mess of documentation and a mishmash of 'glob' type handling and 'regex' handling. Now there are *three* problems... :)
I would try:
@match /^https:\/\/domain\.us\/forums\/forumA\/.*$/ //just to see if it worked. Should it work, there's a 'regex' option for matching (well at least including) that is a "/<regex goes here>/<space>//" that is accepted.
posted by zengargoyle at 2:53 PM on July 2, 2022
Then try removing the final "<space>//" bit. It would be helpful if you could provide a couple of actual links (change the domain parts or words in the path as needed).
I do think you're right in that they messed up some finer details of trying to do just plain '*' for simple things. And I would suspect that they are building a 'regex' out of non-regex strings and really only do regex. (I've done this myself!) and they just missed some use cases. If '@match' is pretty much the same code as '@include' it should handle a regex.
posted by zengargoyle at 3:31 PM on July 2, 2022
I do think you're right in that they messed up some finer details of trying to do just plain '*' for simple things. And I would suspect that they are building a 'regex' out of non-regex strings and really only do regex. (I've done this myself!) and they just missed some use cases. If '@match' is pretty much the same code as '@include' it should handle a regex.
posted by zengargoyle at 3:31 PM on July 2, 2022
Thanks zengargole. I've tried the matching string posted above, but it didn't match and run the userscript. I also tried it using the @include style, but it didn't work either.
The URLs are something like:
For basecamp - (9's are the account number and 0 and 1's are the project numbers - these urls sometimes have additional path after the project number that would still need to be wildcarded in)
project A: https://3.basecamp.com/999999/projects/000000
project B: https://3.basecamp.com/999999/projects/111111
and
For band.us (1 and 0 are "forum" numbers)
forum A: https://band.us/band/1111111
forum B: https://band.us/band/0000000
and
subreddit A: https://old.reddit.com/r/verygoodsubreddit/
subreddit B: https://old.reddit.com/r/verybadreddit/
All of these URLS have associated tools that go with them - think like Trello or Todoist or a google spreadsheet. If I can get the path matching to work on this telegram sharing userscript in Tampermonkey, I'd be golden.
posted by Brent Parker at 5:06 PM on July 2, 2022
The URLs are something like:
For basecamp - (9's are the account number and 0 and 1's are the project numbers - these urls sometimes have additional path after the project number that would still need to be wildcarded in)
project A: https://3.basecamp.com/999999/projects/000000
project B: https://3.basecamp.com/999999/projects/111111
and
For band.us (1 and 0 are "forum" numbers)
forum A: https://band.us/band/1111111
forum B: https://band.us/band/0000000
and
subreddit A: https://old.reddit.com/r/verygoodsubreddit/
subreddit B: https://old.reddit.com/r/verybadreddit/
All of these URLS have associated tools that go with them - think like Trello or Todoist or a google spreadsheet. If I can get the path matching to work on this telegram sharing userscript in Tampermonkey, I'd be golden.
posted by Brent Parker at 5:06 PM on July 2, 2022
This thread is closed to new comments.
posted by Blue Jello Elf at 9:38 AM on July 2, 2022