Devtool mobile

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

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

  1. // ==UserScript==
  2. // @name Devtool mobile
  3. // @version 1.3
  4. // @description 모바일에서 개발자도구를 열 수 있게 합니다.
  5. // @author ㅇㅇ
  6. // @license MIT
  7. // @match *://*/*
  8. // @grant none
  9. // @namespace https://greasyfork.org/users/1426529
  10. // ==/UserScript==
  11.  
  12. (function () {
  13. 'use strict';
  14.  
  15. var erudaLoaded = false;
  16. var erudaScript = null;
  17. var touchCount = 0;
  18. var touchTimer = 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. document.addEventListener('touchstart', function (e) {
  46. if (e.touches.length === 2) { // 두 손가락 터치 감지
  47. touchCount++;
  48.  
  49. if (touchTimer) {
  50. clearTimeout(touchTimer);
  51. }
  52.  
  53. touchTimer = setTimeout(function () {
  54. touchCount = 0; // 300ms 이후 터치 카운트 초기화
  55. }, 300);
  56.  
  57. if (touchCount === 3) { // 3번 터치 시 동작
  58. erudaLoaded ? unloadEruda() : loadEruda();
  59. touchCount = 0;
  60. }
  61. }
  62. });
  63.  
  64. document.addEventListener('keydown', function (e) {
  65. if (e.ctrlKey && e.shiftKey && e.key === 'R') {
  66. erudaLoaded ? unloadEruda() : loadEruda();
  67. }
  68. });
  69.  
  70. if (localStorage.getItem('erudaLoaded') === 'true') {
  71. loadEruda();
  72. }
  73. })();