Sunday, January 12, 2025

Bypassing Google "URL Swapping" in Firefox on Mac

Problem: Users on my wifi network can't click on ad links in Google Search results because those links redirect to the ad.doubleclick.net domain, which is blocked by my Pi-hole. The user ends up on a page with this error message:

Unable to connect. An error occurred during a connection to ad.doubleclick.net. 

Unable to connect. An error occurred during a connection to ad.doubleclick.net.

This happens on Firefox (as of the time of this post, January 2025) because Google is doing something a little bit sneaky: If you mouse over a hyperlink in a sponsored ad in a set of Google search results, it appears to be a normal hyperlink. However, as soon as you click on that link, Google swaps out the target of that link to be a different one than the one that was displayed -- and that's where the link ends up taking you.

(In more technical terms: Google appears to be using JavaScript's onClick event to cancel the navigation to the original href; then replaces the original href with the new href; and then proceeds to navigate to that new destination.)

For example, one of the results when I searched Google just now for "new wireless service" was https://www.verizon.com/plans/unlimited. However, clicking on that link actually navigated me to an URL starting with https://ad.doubleclick.net/searchads/link/click?lid=... . 

You can actually see the swapped-in hyperlink by using the browser's back button to return to the Google search results page, and mousing over the clicked hyperlink again. You'll see that preview of the destination URL for that same link has now changed! (The same happens if you right-click on the target link, then cancel the right-click context menu, and hover over the link again.)

My family members from time to time actually want to click on a sponsored Google search result, and have the navigation work properly. However, I don't want to whitelist the entire "ad.doubleclick.net" domain at my Pi-hole, since that would likely result in a lot more distracting ads being rendered as we use the web. 

I searched for a Firefox add-on which would prevent hyperlink URL destinations being changed from the preview URL that was shown prior to clicking on them, but couldn't find one that seemed trustworthy. 

(I do already run EFF's Privacy Badger add-on, which purports to include this particular functionality; but for whatever reason, it isn't working for me in Firefox as of the time of this post. Possibly Google has recently updated the mechanism that they use to perform their URL-swapping in Firefox; and Privacy Badger hasn't yet been correspondingly updated.)

Workaround / Solution

To my surprise, Google doesn't seem to perform their URL replacement when the search link is activated by the Return key, instead of by a click! Therefore, a crude-but-effective workaround is as follows, when looking at a page of Google search results:

  1. Hit the Tab key until the desired link has the focus. 
    • (Alternatively, double-click a word of text near the target link to select it; then press Tab and/or Shift-Tab from there until the desired link has the focus.)
  2. Press Return to activate the link.

This workaround does have the advantage of not needing any browser add-on to work!

When doing this, Google (apparently) doesn't have any JavaScript in place to hijack the link destination; the client browser navigates directly to the actual URL shown in the browser's preview, without being redirected through ad.doubleclick.net (or any other domain).

Friday, December 20, 2024

Getting deep recursion to work in a simple Ruby program on Mac

As part of one of my Advent of Code 2024 solutions, I wrote a small program that included a fairly deep level of recursion. 

When run on my Mac, using Ruby 2.7.2, the program failed to run to completion, generating a stack trace like this (shown in part for brevity):

Traceback (most recent call last):
    3304: from day-16/day-16-part-1-dfs.rb:125:in `<main>'
    3303: from day-16/day-16-part-1-dfs.rb:86:in `explore_map'
    3302: from day-16/day-16-part-1-dfs.rb:86:in `each'
    3301: from day-16/day-16-part-1-dfs.rb:96:in `block in explore_map'
    3300: from day-16/day-16-part-1-dfs.rb:86:in `explore_map'
     ... 3292 levels...
day-16/day-16-part-1-dfs.rb:87:in `key?': stack level too deep (SystemStackError)

I could have fixed this by rewriting my recursive function to use a queue instead, but I wanted to see if I could change my runtime configuration to get my program to run as-is; and I was able to do so! I ended up needing to change TWO things to get the program to run successfully.

First, I needed to increase the system stack size limit for my Mac, for the current terminal session. For my particular program, I needed to set it near my machine's max:

ulimit -s 65520

(The default stack size limit had been 8176.)

Making just that change allowed my program (when run from that terminal session -- not from my IDE) to reach a deeper count of recursions; but it still failed with a similar error:

Traceback (most recent call last):
    10920: from day-16/day-16-part-1-dfs.rb:125:in `<main>'
    10919: from day-16/day-16-part-1-dfs.rb:86:in `explore_map'
    10918: from day-16/day-16-part-1-dfs.rb:86:in `each'
    10917: from day-16/day-16-part-1-dfs.rb:96:in `block in explore_map'
    10916: from day-16/day-16-part-1-dfs.rb:86:in `explore_map'
     ... 10908 levels...

day-16/day-16-part-1-dfs.rb:32:in `hash': stack level too deep (SystemStackError)

Second, I needed to set an environment variable to increase the Ruby VM's maximum allowed stack size. For this "toy" program, I just picked an arbitrary very large value:

export RUBY_THREAD_VM_STACK_SIZE=50000000

With that change also in place, my program was able to successfully run to completion!

I did end up refactoring my solution from using a depth-first search to a breadth-first search, which, in addition to not needing to deal with Ruby's limit on recursion stack depth, was a lot more efficient for solving that particular problem.

I wanted to make a note on what I did, though, so that if I ever face a situation again where I'm bumping up against a Ruby stack depth limit (and a solution other than increasing the limit isn't called for), then I'll be able to remember what I did this last time!

Sunday, October 06, 2024

ClipEmoji.com Updated With New Unicode v16.0 Emoji

Despite the fact that emoji pickers are built into major desktop operating systems these days -- as well as into some specific apps like WhatsApp and Slack -- I still find myself using my own site ClipEmoji.com for quickly getting a copy of particular emoji characters to paste into prose I'm writing.

As such, I took some time this afternoon to make a small update to ClipEmoji.com to add the few recently-added new emoji characters in the Unicode v16.0 Emoji set, such as "🫩" ("face with bags under eyes").

Additionally -- and probably more notably! -- I noticed that the Unicode Consortium added in this version a bunch of new "synonyms" (descriptor words) for existing emoji. For example, the words associated with the simple "👍" were previously:

  • thumbs up +1 hand

Now, in v16.0, the set of synonyms for 👍 is:

  • thumbs up +1 good hand like yes

Since the search on ClipEmoji.com is powered by these synonym words (plus a few custom additions of my own), you can now search for "like" and 👍 will be included in the filtered search results, for example.

Enjoy!

Friday, July 26, 2024

Computer eye strain sufferers: Try "Eyezen" glasses

First off: I'm not an eye doctor; I'm just a guy who spends a lot of time in front of a computer! Double-check anything I'm telling you here with your optometrist or ophthalmologist before you do anything else with this information.

Secondly: This isn't a paid post; I'm not receiving any kind of compensation from it. I'm just a fan!

The last several years, I had been suffering from moderately severe eye strain while working in front of my computer all day. Even though I have a nice setup where my monitors are set up a a little over two feet away from me, after  working for a solid hour two, my eyes would kind of "cramp up," feeling fatigued. I'd need to either close them for a couple of minutes, or at least spend time intentionally looking at a wall or object a longer distance away (e.g. across the room), in order to let my eyes recover enough to resume looking at my monitors and continue working.

At my most recent optometrist visit several months ago, my optometrist -- shout out to Dr. Staci E.! -- prescribed "Eyezen" glasses. The glasses that I got are designed specifically for "near-distance" vision: Things that I look at far away through them are somewhat blurry; but the glasses produce really excellent clarity when looking at my two-feet-away computer monitors!

glasses

These glasses have made a very positive difference in my day-to-day job. When I sit down at my computer, I swap out my "everyday wear" glasses for the Eyezen glasses, which I just keep at my desk. Wearing the Eyezen glasses while working, my eye strain symptoms have mostly disappeared! I no longer get eye "cramps" or fatigue that forces me to stop working to "un-strain" my eyes on a frequent basis. 

When I get up from my desk, I swap my Eyezen "computer glasses" (as I think of them) back out for my daily wear glasses. This is obviously an extra step, but I haven't found it to be at all onerous. The cost has definitely been worth the benefit.

As I hadn't previously even been aware of the existence of specialized "near-distance vision" glasses, or Eyezen glasses, I figured I'd share my experience to spread the knowledge! My new glasses have really helped me; if you suffer from eye strain while working on a computer all day, consider asking your eye doctor if they might be a good option for you, too.

Monday, June 03, 2024

Vigil RPG 3.0 is now available!

Vigil RPG, my classic-style turn-based role-playing game for iPhone, has been updated to a new major version, 3.0! 

Vigil RPG logo

For the first time in 10 years on the App Store: Vigil RPG is now free to download! Vigil RPG has always been a "premium" title, where paying once got you the full game, with no ads, premium currencies, stamina timers, or other such impediments. Vigil RPG still has none of that, but now you can download Vigil RPG from the App Store and play the first portion of the game for free! After that, the game offers a single, one-time in-app purchase, which permanently unlocks the full game for you across all of your devices.

(And of course -- as is only right!-- I added code such that everyone who bought Vigil RPG prior to this v3.0.0 update will continue to have access to the full game (including the other major updates in the new version) without needing to buy the IAP.)

The other major feature in the Vigil RPG 3.0 update is Honor Mode! Inspired by a certain awesome hit 2023 AAA RPG -- (okay, fine, I'll just come right out and say that it's obviously Baldur's Gate 3) -- players considering themselves Vigil RPG veterans (or just hungry for maximum challenge right out of the gate?) can now optionally take on this challenging new difficulty. It features enhanced boss enemies with new move sets, and like Hardcore mode in the Diablo series before it, PERMADEATH upon defeat!

You can see all of this for yourself via a free download of Vigil RPG on the App Store.

Need an expert opinion first? Read a review of Vigil RPG at TouchArcade.com.

Learn more about Vigil RPG on the Vigil RPG website.