@jaseg checking for the property on `navigator` is pretty standard in terms of JS feature detection so we think this is about as good a solution as any
(unless/until they start obfuscating it)
@jaseg JavaScript dev for a living here, that's the best way to do feature detection, yeah.
You may want to consider making a new node in code, clearing body and appending it inside body as opposed to slamming innerHTML though 🤷♂️
@jaseg thankfully my GotoSocial does not have such a puny limit. I found also out (the hard way) that you have to clear all CSS, otherwise the new content may be illegible.
New approach:
<script type="text/javascript"><!--//--><![CDATA[//><!--
document.addEventListener("DOMContentLoaded", function () {
/* do not run if browser lacks the antifeature */
if (navigator.getEnvironmentIntegrity === undefined)
return;
/* disable all CSS */
for (let elt of document.getElementsByTagName("link"))
elt.disabled = true;
/* replace body content */
var r1 = document.createElement("h1");
r1.appendChild(document.createTextNode("Your browser contains Google DRM!"));
var r2 = document.createElement("p");
r2.innerHTML = '“Web Environment Integrity” is a Google euphemism for DRM (digital restrictions management) that is designed to prevent ad-blocking and allow only browsers authorised by Google (as opposed to e.g. browsers on hobbyist or aftermarket operating systems). In support of an open web, this website does not function with browsers that utilise this kind of DRM. Please install a webbrowser such as <a href="https://invisible-island.net/lynx/lynx.html"><tt>lynx</tt></a> or <a href="https://www.mozilla.org/en-US/firefox/new/">Firefox</a> that better respects everyone’s freedom and supports ad blockers.';
document.getElementsByTagName('body')[0].replaceChildren(r1, r2);
}, false);
//--><!]]></script>
Of course I could do the whole creating of text and element nodes for r2 as well but I figured it’s not that bad for a newly created node tree. If it is @guades please do tell me, I’m more of an assembly, C and Korn Shell developer.
(I put the whole stuff in front of </body> and reversed the conditional in the forth line to test it.)
That being said (I used the OP test conditional above), should it not be…
if (typeof(navigator.getEnvironmentIntegrity) === "undefined")
… because otherwise you can get error messages for use of undefined variables? I think I ran into that once.
@mirabilos @jaseg @guades Apache mod_rewrite is (as usual) your friend. Search down this page for 'Browser Dependent Content':
@mirabilos @jaseg @guades No, you can do it with mod_rewrite, on the user agent string, which contains the browser version.
https://www.whatismybrowser.com/guides/the-latest-user-agent/chrome
@mirabilos @jaseg @guades That may be what you do.
You do you.
@jaseg
Yours is much better, but I proposed a simple filter on UserAgent here:
https://x0f.org/@FreePietje/110782227575268067
Sharing it as I like my
"The fix is to switch to Firefox.
Or circumvent this simple attestation by changing your UserAgent"
IIRC some time ago the idea was floating around to create a new HTTP status/error code: 666 That was for the previous horrible thing that G👀gle did. How about we implement it this time around? Something like: - If UserAgent = G👀gle/Chrome/Chromium/etc then return 666 with "This page was written for the Open Web, but your browser is against that, so we can't serve you this page. The fix is to switch to #Firefox. Or circumvent this simple attestation by changing your UserAgent" #GoogleIsEvil
@jaseg my issue with Firefox is that its android version does not support 98% of extensions anymore. and the only browser for android that supports all the extensions i use (like, say, Stylus for blobcat-shaped buttons on fedi posts, FediAct for remote instance reblobs, Tap To Tab for navigation convenience, Consent-O-Matic against all that usual cookie bullshit) is a chromium-based Kiwi, that also, apparently, has this BS already merged. so yeah, unless there is a firefox fork that offers at least some support for arbitrary desktop extensions for android, im fucked
also, desktop Firefox is ugly (tho this is fixable with userCSS) and mobile Firefox is not adapted to big screens since the exact moment they fucked up the extensions on mobile.
also also, new Firefox can remotely disable your extensions per-website because FUCK USERS.
any actually good browsers?
lynx is a good browser, but not a particularly good mobile browser
Ugghhh. I switched to Kiwi because it was the only Android browser to support the Bypass Paywalls extension.
But, I was able to use most any Firefox extension on most Android Firefox forks. It does t require the extension be on Mozilla Add-Ons, and I have an account there. Just make a custom add-on collection of any that I want to use.
It's a pain to have to add them to the collection before I could use them, but it worked. Used it on Iceraven, Mull, and Fennec F-Droid.
@jaseg I have a new Apache (please don't judge me) rewrite rule for all my webbed sites now
RewriteCond %{HTTP_USER_AGENT} .*Chrome.*
RewriteRule ^(.*)$ /get_firefox.html [L]
@jaseg it brings me memories back.
of when websites would display messages such as "this site does not work on internet explorer, and that's a feature".
back when we believe on the lie of "do not be evil" from google.
well, turns out chrome has become the internet explorer it killed.
@jaseg I first came across this toot in isolation and was going to say "I took a while to get the joke but it was worth it."
Then I realised it wasn't a joke...which is actually even better! Let's hope this trend catches on!