Skip Navigation

Knowledge Request: Rewriting URLs

I can't seem to figure this out. I've been trying out different news aggregator sites to use as a home page. Right now I'm using skimfeed. I like it, but the links all have skimfeed baggage tacked on. Like this: https://skimfeed.com/r.php?q=1148&l=15649995&u=https%3A%2F%2Fxkcd.com%2F3006%2F

Well, the source looks like this:

<span class='boxtitles'><h2><a class='siteurls ts33' href='/news/xkcd.html'>XKCD</a> <a class='siteurls atat' href='http://xkcd.com' rel='nofollow' target='_blank'>+</a></h2></span>

<ul><li class='nl1 bd33'><a href='r.php?q=1148&l=15649995&u=https%3A%2F%2Fxkcd.com%2F3006%2F' target='_blank' rel='nofollow' title='Demons'>Demons</a> </li><li class='nl2 bd75'><a href='r.php?q=1148&l=15642742&u=https%3A%2F%2Fxkcd.com%2F3005%2F' target='_blank' rel='nofollow' </li></ul></div>

Which, to be honest, is Greek to me. I'd like to rewrite the links so that they just look like https://xkcd.com/3006/ I don't really care what the link looks like, per se, the encoded bits. I just don't like the extra skimfeed stuff. Aesthetically.

Is there an extension or something that will help me with this? The couple I've looked at are either too complicated for my caveman brain, or site specific (i.e., remove google tracking). If I'm just being a little too retentive, feel free to let me know that too.

6
6 comments
  • I'm not sure what the best way to make using it convenient is, but you could paste something like this into the JS console to rewrite all the r.php links:

    (function() {
      let links = [...document.getElementsByTagName("a")];
      links.forEach(link => {
        if(link.href.startsWith("https://skimfeed.com/r.php"))
        {
          let url = new URL(link.href);
          let clean_link = url.searchParams.get("u");
          link.href = clean_link;
        }
      });
    })();
    

    The basic idea of my JS snippet is that it looks for all the anchor tags (i.e. <a href='...'>), finds the ones that link to r.php, extracts the u query parameter which appears to contain the actual URL of interest, and then replaces the href attribute of the anchor (i.e. the part of the HTML that contains the destination URL) with the clean URL. That entire snippet of logic is wrapped in an anonymous function which is then immediately called so that you can just paste the snippet in more or less wherever it makes sense to trigger the logic.

    Way back in the day I would've stuck snippets like that into GreaseMonkey scripts, but I haven't messed with that stuff in a long time and I'm not sure which extensions are still good to use for doing that kind of thing.

    Apologies in advance if my snippet is not perfectly correct; I'm not familiar with that site and wrote this off the cuff when I saw your post. Hopefully it's helpful though.

  • Tampermonkey will do what you need. It's not point and click, but writing the custom script shouldn't be too difficult for someone very new. You essentially just need to complete a find and replace upon page load. The %2F and similar costs are just ASCII characters in percent-encoding and can easily be parsed.

    I'm unsure what benefit you get from this though. It seems skimfeed is just trying to capture which lists and posts get visited so they can adjust the site according to popularity. Doing this via an exit link removes any need for cookies (which I didn't check for, so maybe this ain't what they're using it for).

You've viewed 6 comments.