This Ain't A Phone

Automatically redirect from mobile webpages to the non-mobile equivalent

  1. // ==UserScript==
  2. // @name This Ain't A Phone
  3. // @namespace https://schiff.io
  4. // @version 10
  5. // @description Automatically redirect from mobile webpages to the non-mobile equivalent
  6. // @author Hayden Schiff (oxguy3)
  7. // @match *://m.dailykos.com/*
  8. // @match *://m.facebook.com/*
  9. // @match *://m.imdb.com/*
  10. // @match *://mobile.nytimes.com/*
  11. // @match *://m.phys.org/*
  12. // @match *://m.sweclockers.com/*
  13. // @match *://mobile.twitter.com/*
  14. // @match *://m.mediawiki.org/*
  15. // @match *://*.m.wikibooks.org/*
  16. // @match *://m.wikidata.org/*
  17. // @match *://*.m.wikimedia.org/*
  18. // @match *://*.m.wikinews.org/*
  19. // @match *://*.m.wikipedia.org/*
  20. // @match *://*.m.wikiquote.org/*
  21. // @match *://m.wikisource.org/*
  22. // @match *://*.m.wikisource.org/*
  23. // @match *://*.m.wikiversity.org/*
  24. // @match *://*.m.wikivoyage.org/*
  25. // @match *://*.m.wiktionary.org/*
  26. // @match *://m.xkcd.com/*
  27. // @grant none
  28. // @run-at document-start
  29. // ==/UserScript==
  30.  
  31. (function() {
  32. 'use strict';
  33.  
  34. // Checks if the location is a mobile site, and returns the URL of the non-mobile equivalent
  35. // Params: loc: window.location
  36. // Returns: string of new URL, or false if no match
  37. function checkLocation(loc) {
  38.  
  39. // simple hostname replacement rules
  40. var hostRules = [
  41. [ 'm.dailykos.com', 'www.dailykos.com' ],
  42. [ 'm.facebook.com', 'www.facebook.com' ],
  43. [ 'm.imdb.com', 'imdb.com' ],
  44. [ 'm.mediawiki.org', 'www.mediawiki.org' ],
  45. [ 'mobile.nytimes.com', 'www.nytimes.com' ],
  46. [ 'm.phys.org', 'phys.org' ],
  47. [ 'm.sweclockers.com', 'sweclockers.com' ],
  48. [ 'mobile.twitter.com', 'twitter.com' ],
  49. [ 'm.wikidata.org', 'www.wikidata.org' ],
  50. [ 'm.wikisource.org', 'www.wikisource.org' ],
  51. [ 'm.xkcd.com', 'xkcd.com' ]
  52. ];
  53.  
  54. // shared logic for sites that only require a changed hostname
  55. for (var i = 0; i < hostRules.length; i++) {
  56. var rule = hostRules[i];
  57. if (loc.host == rule[0]) {
  58. return loc.href.replace('//'+rule[0], '//'+rule[1]);
  59. }
  60. }
  61.  
  62. // special logic for Wikimedia sites (too many subdomains to list individually)
  63. var wikimediaHosts = [
  64. 'wikipedia.org',
  65. 'wikibooks.org',
  66. 'wikimedia.org',
  67. 'wikinews.org',
  68. 'wikiquote.org',
  69. 'wikisource.org',
  70. 'wikiversity.org',
  71. 'wikivoyage.org',
  72. 'wiktionary.org',
  73. ];
  74. for (var i = 0; i < wikimediaHosts.length; i++) {
  75. var wmHost = wikimediaHosts[i];
  76. if (loc.host.endsWith('.m.'+wmHost)) {
  77. var newHost = loc.host.slice(0, 0 - ('m.'+wmHost).length) + wmHost;
  78. return loc.protocol + "//" + newHost + ":" + loc.port + loc.pathname + loc.search + loc.hash;
  79. }
  80. }
  81.  
  82. return false;
  83. }
  84.  
  85. var destination = checkLocation(window.location);
  86. if (destination !== false) {
  87. window.location.href = destination;
  88. }
  89. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址