Devtool mobile

모바일에서 개발자도구를 열 수 있게 합니다.

当前为 2025-02-24 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Devtool mobile
  3. // @version 1.0
  4. // @description 모바일에서 개발자도구를 열 수 있게 합니다.
  5. // @author ㅇㅇ
  6. // @license MIT
  7. // @match *://*/*
  8. // @grant none
  9. // ! @downloadURL https://m.dcinside.com/board/sff
  10. // ! @updateURL https://m.dcinside.com/board/adguard
  11. // @namespace https://greasyfork.org/users/1426529
  12. // ==/UserScript==
  13.  
  14. (function () {
  15. 'use strict';
  16.  
  17. var erudaLoaded = false;
  18. var erudaScript = null;
  19.  
  20. function loadEruda() {
  21. if (!erudaLoaded) {
  22. erudaScript = document.createElement('script');
  23. erudaScript.src = "//cdn.jsdelivr.net/npm/eruda";
  24. document.body.appendChild(erudaScript);
  25.  
  26. erudaScript.onload = function () {
  27. eruda.init();
  28. eruda.show();
  29. erudaLoaded = true;
  30. localStorage.setItem('erudaLoaded', 'true');
  31. };
  32. }
  33. }
  34.  
  35. function unloadEruda() {
  36. if (erudaLoaded) {
  37. eruda.destroy();
  38. document.body.removeChild(erudaScript);
  39. erudaScript = null;
  40. erudaLoaded = false;
  41. localStorage.setItem('erudaLoaded', 'false');
  42. }
  43. }
  44.  
  45. var touchTimeout;
  46. document.addEventListener('touchstart', function (e) {
  47. if (e.touches.length === 2) {
  48. touchTimeout = setTimeout(function () {
  49. erudaLoaded ? unloadEruda() : loadEruda();
  50. }, 2000);
  51. }
  52. });
  53.  
  54. document.addEventListener('touchend', function () {
  55. if (touchTimeout) {
  56. clearTimeout(touchTimeout);
  57. }
  58. });
  59.  
  60. document.addEventListener('keydown', function (e) {
  61. if (e.ctrlKey && e.shiftKey && e.key==='R') {
  62. erudaLoaded ? unloadEruda() : loadEruda();
  63. }
  64. });
  65.  
  66. if (localStorage.getItem('erudaLoaded') === 'true') {
  67. loadEruda();
  68. }
  69. })();