困ったことにGreasemonkeyはdocuemnt-startのタイミングでwindow.navigator.userAgentを置換しても勝手に元に戻ってしまって役に立たなかった。Tampermonkeyは、動いた。 世の中には3つの嫌われる行いがある。UAをパースしようとすること、UAによってサービスを変えること、やりもせずに諦めることだ。

Formato
JavaScript
Post date
2020-07-10 17:59
Publication Period
Unlimited
  1. // ==UserScript==
  2. // @name fake windows for fools
  3. // @version 1
  4. // @include https://news.yahoo.co.jp/*
  5. // @include https://s.yimg.jp/*
  6. // @run-at docuemnt-start
  7. // @grant none
  8. // ==/UserScript==
  9. // Copyright waived using CC0 1.0 Universal, 2020 dyknon
  10. let ua = window.navigator.userAgent;
  11. let newua = ua.replace(")", "; fake Windows NT 10.0)")
  12. .replace("Linux", "L1nux");
  13. Object.defineProperty(window.navigator, "userAgentOriginal", {value: ua});
  14. Object.defineProperty(window.navigator, "userAgent", {value: newua});
Descargar Printable view

URL of this paste

Embed with JavaScript

Embed with iframe

Raw text