Mobile Link Replacer

Replaces mobile links on web pages with their desktop counterpart.

目前为 2024-01-27 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Mobile Link Replacer
  3. // @namespace
  4. // @version 0.9.0
  5. // @description Replaces mobile links on web pages with their desktop counterpart.
  6. // @author Spencer Ayers-Hale
  7. // @license GPL-3.0-or-later; http://www.gnu.org/licenses/gpl-3.0.txt
  8. // @run-at document-idle
  9. // @match https://*/*
  10. // @match http://*/*
  11. // @exclude https://www.reddit.com/chat/minimize
  12. // @exclude https://www.craigslist.org/static/www/localStorage*
  13. // @exclude https://auth.discogs.com/*
  14. // @exclude https://www.youtube.com/embed/*
  15. // @exclude https://widget.pico.tools/*
  16. // @exclude https://m.stripe.network/*
  17. // @exclude *content.s3.amazonaws.com/*
  18. // @exclude https://cdns.*.gigya.com/*
  19. // @exclude https://platform.twitter.com/*
  20. // @exclude https://myaccount.nytimes.com*
  21. // @exclude *googleapis.com*
  22. // @exclude https://www.google.com/recaptcha/*
  23. // @exclude https://cdn.*.com/widgets/*
  24. // @exclude https://buy.tinypass.com/*
  25. // @exclude https://trinitymedia.ai/player/*
  26. // @exclude https://embed.air.tv/v1/*
  27. // @exclude https://www.11alive.com/embeds/*
  28. // @exclude https://widget.yappaapp.com/*
  29. // @exclude https://authenticate.economist.com/*
  30. // @exclude https://embed.acast.com/*
  31. // @exclude https://o.prod.theintercept.com/checkout/*
  32. // @exclude https://identity-eu.nationalgeographic.com/*
  33. // @exclude *rackcdn.com/*
  34. // @exclude *msi.com/*
  35. // @exclude www.lg.com*
  36. // ==/UserScript==
  37.  
  38. (function() {
  39. 'use strict';
  40.  
  41. var num = document.getElementsByTagName("a").length; //number of links on page
  42. var cnt = 0; //current link number
  43. var newLink;
  44.  
  45. while(cnt < num){
  46. const link = document.getElementsByTagName("a")[cnt].href; //get original link
  47.  
  48. //find and replace
  49. //Wikipedia
  50. newLink = link.replaceAll(/m.wikipedia/gi, 'wikipedia');
  51. //Facebook
  52. newLink = newLink.replaceAll(/m.facebook/gi, 'facebook');
  53. //Twitter
  54. newLink = newLink.replaceAll(/mobile.twitter/gi, 'twitter');
  55. newLink = newLink.replaceAll(/m.twitter/gi, 'twitter');
  56. //IMDB
  57. newLink = newLink.replaceAll(/m.imdb/gi, 'imdb');
  58. //AliExpress
  59. newLink = newLink.replaceAll(/m.aliexpress/gi, 'aliexpress');
  60. //Blogger
  61. if (newLink.indexOf("blogspot.com") > -1){
  62. newLink = newLink.replaceAll(/m=1/gi, 'm=0');
  63. }
  64. //CBS Local
  65. if (newLink.indexOf("cbslocal.com") > -1){
  66. newLink = newLink.replaceAll(/amp/gi, '');
  67. }
  68.  
  69. document.getElementsByTagName("a")[cnt].href=newLink; //write new link to page
  70. cnt++;
  71. }
  72.  
  73. })();