Workaround for Deepl desktop site on mobile phones

Fix Deepl lmt stylesheets so that mobile phones can use the desktop Deepl site at any size.

  1. // ==UserScript==
  2. // @name Workaround for Deepl desktop site on mobile phones
  3. // @namespace DeeplDesktopMobile
  4. // @author Benau
  5. // @license MIT
  6. // @version 1.0
  7. // @description Fix Deepl lmt stylesheets so that mobile phones can use the desktop Deepl site at any size.
  8. // @icon https://static.deepl.com/img/favicon/favicon_32.png
  9. // @match https://www.deepl.com/*
  10. // @grant GM_addStyle
  11. // @grant GM_xmlhttpRequest
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16.  
  17. var stylesheetPattern = /https:\/\/static.deepl.com\/css\/lmt.*/i;
  18.  
  19. function addFixedCSS(url) {
  20. return new Promise((resolve, reject) => {
  21. GM_xmlhttpRequest({
  22. method: "GET",
  23. url: url,
  24. onload: function(response) {
  25. var fixed_css = response.responseText.replace(/\(max-device-width:\s*650px\)/gi, '(max-device-width: 10px)');
  26. fixed_css = fixed_css.replace(/\(max-device-height:\s*650px\)/gi, '(max-device-height: 10px)');
  27. GM_addStyle(fixed_css);
  28. },
  29. onerror: function(error) {
  30. reject(error);
  31. }
  32. });
  33. });
  34. }
  35.  
  36. function removeStylesheets() {
  37. var stylesheets = document.styleSheets;
  38. for (var i = 0; i < stylesheets.length; i++) {
  39. var stylesheet = stylesheets[i];
  40. if (stylesheet.href && stylesheet.href.match(stylesheetPattern)) {
  41. addFixedCSS(stylesheet.href)
  42. stylesheet.ownerNode.remove();
  43. }
  44. }
  45. }
  46.  
  47. removeStylesheets();
  48.  
  49.  
  50. })();

QingJ © 2025

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