Email or username:

Password:

Forgot your password?
Top-level
rugk

Problem 1: I wanted to load the IP ranges directly from the gstatic server, so the result is up-to-date.

However, the server does not set the header for cross-origin requests (CORS), so I had to use the power of a browser extension to actually inject it:
github.com/rugk/googerteller/b

12 comments
rugk

Problem 2: Parsing a JSON is a thing JS is made for, so that's simple enough, but checking subnets is not.

Stackoverflow questions basically are all like “come on, learn that thing and implement it yourself”, but a) as a dev you should know that this is certainly a step to use a library, especially given that b) I really really do not want to care thinking about parsing IPv6 IPs now.

rugk

Fortunately I found a nice subnet checking library by @natevancouver
and after a facepalm from my side (check the issues 🤦‍♂️) that also worked flawless in the browser environment I was basically using.

npmjs.com/package/is-in-subnet

rugk

Problem 3: However, having a list of IPs and access to web requests (the listener is simple) is not enough.

As browsers are too high-level, we only get the URL/domain here. However, we need to get the IP here.

Fortunately Firefox (only!) has an API: developer.mozilla.org/en-US/do

rugk

Problem 4: Having all that, we should be done, should not we? Well… no! I still hear nothing!

Playing a sound was surprisingly difficult, given browsers usually now limit that websites (browser extensions are basically websites) should not play a random sound out of nowhere.

rugk

I am still trying here, but depending on how you load the sound file, you may end up getting weird errors.

The worst thing is that you need to copy the sound element to have multiple sound effects starting at the same time, so they can overlap each other.

rugk

All in all, note that due to the way ad blockers are/will be handled in Chrome, some of these things I did will not be possible. This includes modifying by injecting a header + the DNS API is not even there in Chrome.

For what this means, check out this:

theverge.com/2022/6/10/2313102

rugk

(Thread is a response to twitter.com/bert_hu_bert/statu, who made the same thing as a C app that works across applications.)

Martin Giger

@rugk where are you loading your sound and what codec are you using? I found that using some codecs will not work out of the box on all OSes when playing in the background page for github.com/freaktechnik/notifi

Martin Giger

@rugk just having the host permission for the domain should solve this though?

Go Up