How do I prevent sites (in a browser) from treating me differently because of my OS preference?

1

1

One site that I use has a browser check that it performs, and because my browsers indicate that they're Linux, and not Windows or Mac it pops up (on every page) a warning that I'm using an "unsupported" OS.
I've tried falsifying the user agent, but Chrome seems to not be saving that setting, and user-agent switcher extensions seem to be ineffective.

The browser detection appears to be bundled into a single javascript file. So, I figure if I can blacklist or ban that file then it'll stop bugging me about my "unsupported" OS.

So, how would I go about blacklisting or banning that file? Solutions that work for multiple browsers are a bonus.

killermist

Posted 2013-02-13T23:43:43.247

Reputation: 1 886

Can you post a link to that page? – Dennis – 2013-02-13T23:57:07.487

@Dennis https://myharrison.harrison.edu/secure/student/loginstu.aspx

– killermist – 2013-02-14T00:56:46.803

Answers

1

You can achieve the same result with a user script. It won't prevent the external JavaScript from loading, but it will disable the JavaScript functions alert() and confirm(). Removing the banner with JavaScript could cause flickering, but you can inject CSS to hide it.

User script

// ==UserScript==
// @name        No Nagging
// @description Disables nagging on harrison.edu
// @version     1.2
// @include     *://harrison.edu/*
// @include     *://*.harrison.edu/*
// @run-at      document-start 
// ==/UserScript==

var script = document.createElement('script');
var style = document.createElement('style');

script.appendChild(document.createTextNode(
    'window.alert=function(){};' + 
    'window.confirm=function(){};'
));

style.appendChild(document.createTextNode(
    '.topmenubar{display:none;}'
));

var interval = setInterval(function() {
    if (document.head) {
        document.head.appendChild(script);
        document.head.appendChild(style);
        clearInterval(interval);
    }
}, 10);

How it works

The first four instructions create <script> and <style> elements. The JavaScript inside <script> replaces the global functions alert() and confirm() with empty functions; the CSS inside <style> hides the banner.

<script>
    window.alert=function(){};
    window.confirm=function(){};
</script>

<style>
    .topmenubar{display:none;}
</style>

Next, we create an interval that checks every 10 ms in the <head> element already exists.

When it does, we append the created elements to <head> and cancel the interval.

How to install

  1. Save the script as no-nagging.user.js.

    • Open chrome://extensions.

    • Drag no-nagging.user.js into the open tab.

    OR

    • Close Chrome and reopen it by executing the following command:

      google-chrome --easy-off-store-extension-install
      
    • Drag no-nagging.user.js into the address bar.

  2. Click Add.

Dennis

Posted 2013-02-13T23:43:43.247

Reputation: 42 934

Is there a way to also remove (if present) the span block with id=IsSupportedPlatform ?
I think that would be better than having to use an adblock extension, which I guess I trust fairly well, but I'd prefer to not use if I don't have to.
– killermist – 2013-02-14T03:52:05.077

I've updated my answer. – Dennis – 2013-02-14T12:16:06.213

hmmm. If I drag and drop the file anywhere but the address bar on chrome:/extensions (singular doesn't exist) it does nothing. Dropped to the address bar, I get http://img441.imageshack.us/img441/6315/userjsproblem.png whose link leads to http://support.google.com/chrome_webstore/bin/answer.py?hl=en&answer=2664769&p=crx_warning So, I'm kind of stuck on how to proceed. I remember with Opera, adding .user.js files was as simple as just putting them in the right directory. Google seems to love making Chrome more complicated, I guess.

– killermist – 2013-02-14T13:53:35.160

That might depend on the GUI. Dragging works in Unity. I've added a second approach. – Dennis – 2013-02-14T14:10:28.943

Excellent. Using google-chrome --easy-off-store-extension-install to get it loaded works. It still shows the banner, but the banner has no content, which I'm happy with. The ad blocker was able to surgically remove the whole banner (treating it as an ad). – killermist – 2013-02-14T16:21:25.050

I've modified the script so it removes the entire table, not just the <span> element. – Dennis – 2013-02-14T17:06:26.427

let us continue this discussion in chat

– killermist – 2013-02-14T19:50:57.097

3

You could use an ad-blocker like AdBlock. You can then block the file by its URL.

Aluísio A. S. G.

Posted 2013-02-13T23:43:43.247

Reputation: 2 278

Nifty. Looks like a total of 2 rules were all I needed. One to remove the text warning that was displaying and another to block the file. – killermist – 2013-02-14T00:08:56.547