选择和复制还原器(通用)

破解锁右键,解除禁止复制、剪切、选择文本、右键菜单、文字复制、文字选取、图片右键等限制。增强功能:Alt键超连结文字选取。

目前为 2023-07-30 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Selection and Copying Restorer (Universal)
  3. // @name:zh-TW Selection and Copying Restorer (Universal)
  4. // @name:zh-CN 选择和复制还原器(通用)
  5. // @version 1.17.0.0
  6. // @description Unlock right-click, remove restrictions on copy, cut, select text, right-click menu, text copying, text selection, image right-click, and enhance functionality: Alt key hyperlink text selection.
  7. // @namespace https://gf.qytechs.cn/users/371179
  8. // @author CY Fung
  9. // @supportURL https://github.com/cyfung1031/userscript-supports
  10. // @run-at document-start
  11. // @match http://*/*
  12. // @match https://*/*
  13. // @exclude /^https?://\S+\.(txt|png|jpg|jpeg|gif|xml|svg|manifest|log|ini)[^\/]*$/
  14. // @exclude https://github.dev/*
  15. // @exclude https://www.photopea.com/*
  16. // @exclude https://drive.google.com/*
  17. // @exclude https://mail.google.com/*
  18. // @exclude https://www.google.com/maps/*
  19. // @exclude https://www.dropbox.com/*
  20. // @exclude https://outlook.live.com/mail/*
  21. // @icon https://github.com/cyfung1031/userscript-supports/raw/main/icons/selection-copier.png
  22. // @grant GM_registerMenuCommand
  23. // @grant GM_unregisterMenuCommand
  24. // @grant GM.setValue
  25. // @grant GM.getValue
  26. // @grant GM_addValueChangeListener
  27. // @grant unsafeWindow
  28. // @inject-into page
  29.  
  30. // @compatible firefox Violentmonkey
  31. // @compatible firefox Tampermonkey
  32. // @compatible chrome Violentmonkey
  33. // @compatible chrome Tampermonkey
  34. // @compatible opera Violentmonkey
  35. // @compatible opera Tampermonkey
  36. // @compatible safari Stay
  37. // @compatible edge Violentmonkey
  38. // @compatible edge Tampermonkey
  39. // @compatible brave Violentmonkey
  40. // @compatible brave Tampermonkey
  41.  
  42. // @description:zh-TW 破解鎖右鍵,解除禁止復制、剪切、選擇文本、右鍵菜單、文字複製、文字選取、圖片右鍵等限制。增強功能:Alt鍵超連結文字選取。
  43. // @description:zh-CN 破解锁右键,解除禁止复制、剪切、选择文本、右键菜单、文字复制、文字选取、图片右键等限制。增强功能:Alt键超连结文字选取。
  44.  
  45. // @description:ja 右クリックを解除し、コピー、切り取り、テキスト選択、コンテキストメニュー、テキストのコピー、テキストの選択、画像の右クリックなどの制限を解除します。機能の強化:Altキーでハイパーリンクテキストの選択ができます。
  46. // @description:ko 우클릭 잠금 해제, 복사, 잘라내기, 텍스트 선택, 컨텍스트 메뉴, 텍스트 복사, 텍스트 선택, 이미지 우클릭 등의 제한을 해제합니다. 기능 강화: Alt 키로 하이퍼링크 텍스트 선택.
  47. // @description:ru Взломать запрет правой кнопкой мыши, снять ограничения на копирование, вырезание, выбор текста, контекстное меню, копирование текста, выбор текста, правая кнопка мыши на изображении и т.д. Усиление функций: выбор текста гиперссылки с помощью клавиши Alt.
  48. // @description:af Ontsloot regskliek, verwyder beperkings op kopieer, uitknip, teks selekteer, konteks-menu, teks kopieer, teks selekteer, prentjie regskliek, ensovoorts. Versterk funksie: Alt-sleutel vir skakelteks seleksie.
  49. // @description:az Sağ klikkiləri açın, kopyala, kəs, mətn seçin, kontekst menyusu, mətni kopyalayın, mətni seçin, şəkil sağ klikk, kimi məhdudiyyətlərdən azad olun. Gücləndirilmiş funksiya: Alt düyməsi ilə hiperlink mətn seçimi.
  50. // @description:id Buka blokir klik kanan, hapus pembatasan penyalinan, pemotongan, memilih teks, menu klik kanan, menyalin teks, memilih teks, klik kanan gambar, dan sebagainya. Peningkatan fitur: Pilih teks tautan dengan tombol Alt.
  51. // @description:ms Buka kunci klik kanan, hapuskan sekatan salin, potong, pilih teks, menu klik kanan, salin teks, pilih teks, klik kanan imej, dan lain-lain. Tingkatkan ciri: Pilih teks pautan dengan tombol Alt.
  52. // @description:bs Otključaj desni klik, ukloni ograničenja kopiranja, izrezivanja, odabira teksta, desni klik menija, kopiranja teksta, odabira teksta, desni klik na slici i tako dalje. Poboljšane funkcije: Odabir teksta hiperveze pomoću tipke Alt.
  53. // @description:ca Desbloqueja el clic dret, elimina les restriccions de còpia, talla, selecció de text, menú contextual, còpia de text, selecció de text, clic dret a la imatge, i així successivament. Millora de funcionalitats: selecció de text d'enllaç amb la tecla Alt.
  54. // @description:cs Odemkněte pravé tlačítko myši, odstraňte omezení kopírování, výstřižek, výběru textu, kontextového menu, kopírování textu, výběru textu, pravého tlačítka myši na obrázku atd. Vylepšené funkce: Výběr textu hypertextového odkazu pomocí klávesy Alt.
  55. // @description:da Lås højreklik op, fjern begrænsninger for kopiering, klipning, tekstvalg, højreklikmenu, tekstkopiering, tekstvalg, højreklik på billede osv. Forbedrede funktioner: Vælg teksten af hyperlink ved hjælp af Alt-tasten.
  56. // @description:de Entsperren Sie den Rechtsklick, entfernen Sie Einschränkungen für Kopieren, Ausschneiden, Textauswahl, Rechtsklickmenü, Textkopieren, Textauswahl, Rechtsklick auf ein Bild usw. Verbesserte Funktionen: Auswahl des Textes eines Hyperlinks mit der Alt-Taste.
  57. // @description:et Vabastage paremklõps, eemaldage piirangud kopeerimisel, lõikamisel, teksti valimisel, paremklõpsumenüüs, teksti kopeerimisel, teksti valimisel, pildi paremklõpsamisel jne. Täiustatud funktsioonid: valige hüperlingi tekst Alt-klahviga.
  58. // @description:es Desbloquear clic derecho, eliminar restricciones de copia, corte, selección de texto, menú contextual, copia de texto, selección de texto, clic derecho en imagen, etc. Mejora de funciones: selección de texto de hipervínculo con la tecla Alt.
  59. // @description:eu Eskubiko klika desblokeatu, kopiatzearen murrizketak kentzen, ebakiak, testua hautatu, klik ezkerreko menua, testuaren kopia, testuaren hautapena, irudiko eskubiko klika, eta abar. Hobetu funtzioak: Hiperestekaren testu hautapena Alt tekla bidez.
  60. // @description:fr Débloquez le clic droit, supprimez les restrictions de copie, de découpe, de sélection de texte, de menu clic droit, de copie de texte, de sélection de texte, de clic droit sur l'image, etc. Améliorez les fonctionnalités : Sélectionnez le texte du lien hypertexte avec la touche Alt.
  61. // @description:gl Desbloquear o clic dereito, eliminar as restricións de copia, recorte, selección de texto, menú contextual, copia de texto, selección de texto, clic dereito na imaxe, etc. Mellora das funcións: Seleccione o texto do hipervínculo coa tecla Alt.
  62. // @description:hr Otključajte desni klik, uklonite ograničenja kopiranja, izrezivanja, odabira teksta, desni klik izbornika, kopiranja teksta, odabira teksta, desni klik na slici itd. Poboljšane funkcije: Odaberite tekst hiperlinka pomoću tipke Alt.
  63. // @description:zu Sushintsha isikhuthazo sangokucindezela, lungisa imilayezo yokuqhutshwa, ukuketha umfundi, imenyu yokuqhutshwa, ukukopisha umlayezo, ukukhetha umlayezo, uqhube ikhasi lokucindezelwa kwesithombe, noma kanye. Enhla kwezinhlelo: Khetha umbhalo wohlelo lokuqhubekisa ngekhodi ye-Alt.
  64. // @description:is Opna hægri smell, fjarlægðu takmörk á afriti, klippingu, textavalinu, hægrismelltu valmynd, textaafriti, textavalinu, hægri smelltu á mynd o.fl. Styrktarstig: Veldu texta tengils með Alt-takk
  65. // @description:it Sblocca il clic destro, rimuovi le restrizioni di copia, taglia, selezione del testo, menu contestuale, copia del testo, selezione del testo, clic destro su un'immagine, ecc. Migliora le funzionalità: seleziona il testo del collegamento ipertestuale con il tasto Alt.
  66. // @description:sw Fungua Bonyeza-Kulia, Ondoa Vizuizi vya Kunakili, Kukata, Kuteua Maandishi, Menyu ya Bonyeza-Kulia, Kunakili Maandishi, Kuteua Maandishi, Bonyeza-Kulia kwenye Picha, na kadhalika. Boresha Kazi: Teua Nakala ya Kiunganishi cha Maandishi kwa Kutumia Kitufe cha Alt.
  67. // @description:lv Atbloķēt labo peles pogu, noņemt ierobežojumus attēla kopēšanā, izgriešanā, teksta izvēlē, labā peles kliķa izvēlnē, teksta kopēšanā, teksta izvēlē, un tā tālāk. Uzlabotas funkcijas: Atlaseshiperhipersaites teksts ar Alt taustiņu.
  68. // @description:lt Atrakinti dešinįjį pelės klavišą, pašalinti apribojimus kopijavimui, iškirpimui, teksto pasirinkimui, dešiniojo pelės klavišo meniu, teksto kopijavimui, teksto pasirinkimui, dešinysis pelės klavišas ant paveikslėlio ir tt. Pakeistos funkcijos: Pasirinkite hiperkryžiaus teksto su Alt klavišu.
  69. // @description:hu Feloldja a jobb egérgomb tiltását, megszünteti a másolás, kivágás, szövegkijelölés, jobb egérgomb menü, szövegmásolás, szövegválasztás, kép jobb egérgombjának stb. korlátozásait. Fejlesztett funkciók: Hiperhivatkozás szöveg kijelölése az Alt billentyű segítségével.
  70. // @description:nl Ontgrendel rechtsklikken, verwijder beperkingen op kopiëren, knippen, tekst selecteren, rechtsklikmenu, tekst kopiëren, tekst selecteren, rechtsklikken op afbeelding, enzovoort. Versterk functies: Selecteer tekst van hyperlink met Alt-toets.
  71. // @description:uz O'ng tugmani oching, nusxalash, kesish, matn tanlash, o'ng tugmasi menyusi, matn nusxalash, matn tanlash, tasvirda o'ng tugmani va hokazo chegaralarni bekor qiling. Qo'shimcha imkoniyatlar: Hyperlink matnini Alt tugmasi bilan tanlang.
  72. // @description:pl Odblokuj prawy przycisk myszy, usuń ograniczenia kopiowania, wycinania, zaznaczania tekstu, menu kontekstowego, kopiowania tekstu, zaznaczania tekstu, prawego przycisku myszy na obrazie, itp. Wzmocnione funkcje: Wybierz tekst hiperłącza za pomocą klawisza Alt.
  73. // @description:pt Desbloquear o clique direito, remover restrições de cópia, recorte, seleção de texto, menu de clique direito, cópia de texto, seleção de texto, clique direito em imagem, etc. Melhorar recursos: Selecionar texto do link com a tecla Alt.
  74. // @description:pt-BR Desbloquear o clique direito, remover restrições de cópia, recorte, seleção de texto, menu de clique direito, cópia de texto, seleção de texto, clique direito em imagem, etc. Melhorar recursos: Selecionar texto de hiperlink com a tecla Alt.
  75. // @description:ro Deblocați clic dreapta, eliminați restricțiile de copiere, tăiere, selectare text, meniu clic dreapta, copiere text, selectare text, clic dreapta pe imagine, etc. Îmbunătățirea funcționalității: Selectați textul unui hyperlink cu tasta Alt.
  76. // @description:sq Zbulo klikimin e djathtë, hiqni kufizimet për kopjimin, prerjen, zgjedhjen e tekstit, menynë e klikimit të djathtë, kopjimin e tekstit, zgjedhjen e tekstit, klikimin e djathtë në imazh, dhe të tjera. Përmirësim i funksioneve: Zgjidhni tekstin e lidhjes me tastinë Alt.
  77. // @description:sk Odomknite pravé tlačidlo myši, odstráňte obmedzenia kopírovania, výrezu, výberu textu, kontextového menu, kopírovania textu, výberu textu, pravého tlačidla myši na obrázku atď. Vylepšené funkcie: Výber textu hypertextového odkazu pomocou klávesy Alt.
  78. // @description:sl Odklenite desni klik, odstranite omejitve kopiranja, izrezovanja, izbire besedila, desni klik menija, kopiranja besedila, izbire besedila, desni klik na sliki itd. Izboljšane funkcije: Izberite besedilo hiperpovezave s tipko Alt.
  79. // @description:sr Одкључајте десни клик, уклоните ограничења за копирање, исецање, избор текста, десни клик мени, копирање текста, избор текста, десни клик на слици итд. Побољшане функције: Изаберите текст хипервезе притиском на тастер Alt.
  80. // @description:fi Poista oikean hiiren painikkeen esto, poista rajoitukset kopioinnilta, leikkaamiselta, tekstin valinnalta, oikean hiiren painikkeen valikolta, tekstin kopiointilta, tekstin valinnalta, kuvan oikealta hiiren painikkeelta jne. Paranna toimintoja: Valitse hyperlinkin teksti Alt-näppäimellä.
  81. // @description:sv Lås upp högerklick, ta bort begränsningar för kopiering, klippning, textval, högerklickmeny, textkopiering, textval, högerklick på bild, etc. Förbättra funktioner: Välj text av hyperlänk med Alt-tangenten.
  82. // @description:vi Mở khóa chuột phải, loại bỏ hạn chế sao chép, cắt, chọn văn bản, menu chuột phải, sao chép văn bản, chọn văn bản, chuột phải trên hình ảnh, vv. Tăng cường tính năng: Chọn văn bản liên kết với phím Alt.
  83. // @description:tr Sağ tıklamayı açın, kopyalama, kesme, metin seçme, sağ tık menüsü, metin kopyalama, metin seçme, resimde sağ tıklama vb. kısıtlamaları kaldırın. İyileştirilmiş işlevler: Alt tuşuyla bağlantı metni seçin.
  84. // @description:be Разблакаваць правы клік, скасаваць абмежаванні па капіраванні, выразі, выбару тэксту, кантэкстнага меню, капіравання тэксту, выбару тэксту, правага кліку на малюнку і г. д. Пашыраныя функцыі: Выберыце тэкст гіперспасылкі з дапамогай клавішы Alt.
  85. // @description:bg Разкодирайте десен бутон, премахнете ограниченията за копиране, изрязване, избор на текст, контекстно меню, копиране на текст, избор на текст, десен бутон върху изображение и т.н. Подобрени функции: Избор на текст на хипервръзка с бутона Alt.
  86. // @description:ky Оң жаңыкты ачыңыз, көчүрмө, тандоо тексти, оң кликтык меню, текстти көчүрүү, тексти тандаңыз, сүрөттө оң кликтүү боюнча чеделерди алыңыз ж.б. Коюлу функциялар: Alt түймөсү боюнча желек текстти тандаңыз.
  87. // @description:kk Оң басқару түймесін ашыңыз, көшіру, мәтінді таңдау, оң баспас меню, мәтінді көшіру, мәтінді таңдау, суретте оң баспас еткізу ж.б. шектіліктерді алыңыз. Дайындауларды жеткізіңіз: Alt түймесімен қосымша түймен текстті таңдаңыз.
  88. // @description:mk Отклучете го десниот клик, отстрани ограничувања за копирање, исечење, избор на текст, десни клик мени, копирање на текст, избор на текст, десен клик на слика итн. Подобрување на функциите: Изберете текст на хиперлинк со копчето Alt.
  89. // @description:mn Зүүн дараалжаа сэргээх, хуулах, текст сонгох, зүүн дараалжын цэс, текст хуулах, текст сонгох, зураг дээр зүүн дараахыг сонгох гэх мэт хязгаарыг цуцлах. Үйлдэл нэмэх: Alt товчлуур ашиглан холбоосын текстээ сонгоно уу.
  90. // @description:uk Розблокуйте правий клік, видаліть обмеження щодо копіювання, вирізання, вибору тексту, контекстного меню, копіювання тексту, вибору тексту, правий клік на зображенні тощо. Покращені функції: Вибір тексту гіперпосилання за допомогою клавіші Alt.
  91. // @description:el Ξεκλειδώστε το δεξί κλικ, καταργήστε τους περιορισμούς αντιγραφής, αποκοπής, επιλογής κειμένου, μενού δεξιού κλικ, αντιγραφής κειμένου, επιλογής κειμένου, δεξί κλικ σε εικόνα κ.λπ. Βελτιωμένες λειτουργίες: Επιλογή κειμένου υπερσυνδέσμου με το πλήκτρο Alt.
  92. // @description:hy Բացեք աջ կոճակը, հանեք պահեստավորումները ֆայլի պատճենում, նշումը, տեքստի ընտրությունը, աջ կոճակի մենյուում, տեքստի պատճենումը, տեքստի ընտրությունը, աջ կոճակ պատկերի վրա և այլն: Մասնակցային ֆունկցիաների ընդհանուրավորում. Նշեք հիպերհղման տեքստը Alt ստեղնով:
  93. // @description:ur دائیں کلک کھولیں، کاپی، کٹ، متن منتخب کریں، دائیں کلک مینو، متن کاپی، متن منتخب کریں، تصویر پر دائیں کلک وغیرہ کی پابندیوں کو ختم کریں۔ تازہ کاری شدہ خصوصیات: Alt کلید کے ساتھ ہائپر لنک متن کا انتخاب کریں۔
  94. // @description:ar فتح النقرة اليمنى ، إزالة قيود النسخ ، القص ، اختيار النص ، قائمة النقرة اليمنى ، نسخ النص ، اختيار النص ، نقرة يمنى على الصورة ، وما إلى ذلك. تعزيز الوظائف: حدد نص الارتباط باستخدام مفتاح Alt.
  95. // @description:fa باز کردن کلیک راست ، برداشتن محدودیت های کپی ، برش ، انتخاب متن ، منوی کلیک راست ، کپی متن ، انتخاب متن ، کلیک راست بر روی تصویر و غیره. تقویت ویژگی ها: انتخاب متن پیوند با کلید Alt.
  96. // @description:ne दायाँ क्लिक खोल्नुहोस्, प्रतिलिपि, काट, पाठ चयन गर्नुहोस्, दायाँ क्लिक मेनु, पाठ प्रतिलिपि, पाठ चयन, तस्वीरमा दायाँ क्लिक, आदिको सीमाहरू हटाउनुहोस्। सुधारिएका सुविधाहरू: एल्ट बटनसहित हायपरलिंक पाठ छान्नुहोस्।
  97. // @description:mr उजवा क्लिक अनलॉक करा, प्रतिलिपि, कट, मजकूर निवडा, उजवा क्लिक मेनू, मजकूर प्रतिलिपि, मजकूर निवडा, प्रतिमेवर उजवा क्लिक इत्यादी सीमांकन काढा. सुधारित क्षमता: आल्ट की बटणाच्या मदतीने हायपरलिंकमधील मजकूर निवडा.
  98. // @description:hi दायीं क्लिक अनलॉक करें, प्रतिलिपि, कट, पाठ चयन करें, दायीं क्लिक मेन्यू, पाठ प्रतिलिपि, पाठ चयन, छवि पर दायीं क्लिक इत्यादि प्रतिबंधों को हटाएँ। सुधारित सुविधाएं: एल्ट कुंजी के साथ हाइपरलिंक पाठ चयन करें।
  99. // @description:as সোণা ক্লিক আনলক কৰক, প্ৰতিলিপি কৰক, কেটা কৰক, পাঠ বাছনি কৰক, সোণা ক্লিক মেনু, পাঠৰ প্ৰতিলিপি কৰক, পাঠ বাছনি কৰক, ছবিৰ সোণা ক্লিক আদিক। উন্নত সুবিধাসমূহ: আল্ট বুটামটো সহ হাইপাৰলিংকৰ পাঠ বাছনি কৰক।
  100. // @description:bn ডান ক্লিক আনলক করুন, কপি, কাট, পাঠ নির্বাচন করুন, ডান ক্লিক মেনু, পাঠ কপি, পাঠ নির্বাচন, চিত্রে ডান ক্লিক ইত্যাদি সীমাবদ্ধতা অপসারণ করুন। উন্নত বৈশিষ্ট্যগুলি: এল্ট বাটন সহ হাইপারলিংক পাঠ নির্বাচন করুন।
  101. // @description:pa ਸੱਜਾ ਕਲਿੱਕ ਖੋਲੋ, ਪਾਉਣੀ, ਕੱਟੋ, ਲਿਖਤ ਚੁਣੋ, ਸੱਜਾ ਕਲਿੱਕ ਮੀਨੂ, ਲਿਖਤ ਪਾਉਣੀ, ਲਿਖਤ ਚੁਣੋ, ਚਿੱਤਰ 'ਤੇ ਸੱਜਾ ਕਲਿੱਕ ਵਗੈਰਹ ਪਾਬੰਦੀਆਂ ਹਟਾਓ। ਸੁਧਾਰਿਤ ਫੀਚਰਾਂ: ਐਲਟ ਬਟਨ ਨਾਲ ਹਾਇਪਰਲਿੰਕ ਦੀ ਲਿਖਤ ਚੋਣ ਕਰੋ।
  102. // @description:gu જમણી ક્લિક ખોલો, કૉપિ, કાપો, ટેક્સ્ટ પસંદ કરો, જમણી ક્લિક મેનૂ, ટેક્સ્ટ કૉપિ, ટેક્સ્ટ પસંદ, ચિત્ર પર જમણી ક્લિક વગેરે પાબંધીઓ કાઢો. સુધારેલી વૈશિષ્ટ્યો: એલ્ટ બટન સાથે હાયપરલિંકના ટેક્સ્ટ પસંદ કરો.
  103. // @description:or ଡାହାଣହାତରେ ଖୋଲନ୍ତୁ, କପି କରିବା, କଟି କରିବା, ପାଠବାରେ ଚୟନ କରିବା, ଡାହାଣହାତ ମେନୁ, ପାଠବା ଏବଂ ଚିତ୍ର ଡାହାଣହାତ ପାଠ ଚୟନର ମର୍ମ୍ମ କେତେଟେ ପାରିବେ ବିବରଣୀ ମିଳିବା: ଅଲ୍ଟ କୀ ହେଇଲା ହାଇପରଲିଙ୍କ ପାଠ ଚୟନ।
  104. // @description:ta வலப்பதிவு மூலம் தடைகளை நீக்குங்கள், நகலைப் பட்டைக்கு மாற்றுங்கள், உரையை தேர்வு செய்யுங்கள், வலப்பதிவு மெனு, உரை நகலைப் படக்குகள், உரை தேர்வுகளைப் படக்குகள், பட வலப்பதிவுகள் போன்ற வரைபடங்களின் வரைபடத்தை அதிகரித்துக்கொள்ளுங்கள். அதிகப்படியான செயல்பாடு: அல்ட் விசை அடைவு உரை தேர்வு.
  105. // @description:te డౌన్‌లోడ్ చేయడానికి రైట్ క్లిక్ ని అనుమతించండి, నకలు, కట్, వచ్చేయి, కుడిచేయండి, టెక్స్ట్ నకలుచేయండి, చిత్రం రైట్ క్లిక్ చేయండి, అదనపు కొంత క్షేత్రాలను మెరుగుపరచండి: అల్ట్ కీ హైపర్‌లింక్ టెక్స్ట్ ఎంపికను పెంచుతుంది.
  106. // @description:kn ಬಲ ಕ್ಲಿಕ್ ಬಿರುದುಗಳನ್ನು ತೆರೆಯಲು ಅನುಮತಿಸುವುದು, ನಕಲು, ಕಟ್ಟು, ಆಯ್ಕೆ ಮಾಡುವುದು, ಬಲ ಕ್ಲಿಕ್ ಮೆನು, ಪಠ್ಯ ನಕಲು, ಪಠ್ಯ ಆಯ್ಕೆ, ಚಿತ್ರ ಬಲ ಕ್ಲಿಕ್ ಮುಂತಾದ ಮಿತಿಗಳನ್ನು ತೆಗೆದುಹಾಕಿ. ಪ್ರಭಾವವನ್ನು ಹೆಚ್ಚಿಸುವುದು: Alt ಕೀ ಹೈಪರ್‌ಲಿಂಕ್ ಪಠ್ಯ ಆಯ್ಕೆ.
  107. // @description:ml വലത് ക്ലിക്ക് അനുവദനീയമാക്കുക, പകരം പകർത്തുക, ടെക്സ്റ്റ് തിരിച്ചുവയ്ക്കുക, റൈറ്റ്-ക്ലിക്ക് മെനു, ടെക്സ്റ്റ് പകർത്തൽ, ടെക്സ്റ്റ് തിരിച്ചൽ, ചിത്രം റൈറ്റ്-ക്ലിക്ക് എന്നിവ നീക്കംചെയ്യുക. പ്രവർത്തനം വരുത്തുക: Alt കീ ഹൈപർലിങ്ക് ടെക്സ്റ്റ് തിരിച്ചൽ.
  108. // @description:si දකුණු ක්ලික් කරන්න ඉඩ දෙන්න, පිටුව පිරවීම, පෙළ තෝරාගන්නවා, දකුණු ක්ලික් මෙනුව, පෙළ පිරවීම, පෙළ තෝරාගන්න, පින්තුර දකුණු ක්ලික් කරන්න ඇති සීමාවෙන් සහාය ලෙස වැහියාව ඇති ක්ලික් විශේෂිත: Alt යතුර හයිපර්ලින්ක් පෙළ තෝරාගන්න.
  109. // @description:th ปลดล็อกคลิกขวาเพื่อย้าย, ย้าย, เลือกข้อความ, เมนูคลิกขวา, คัดลอกข้อความ, เลือกข้อความ, คลิกขวาภาพ และเพิ่มฟังก์ชัน: คีย์ Alt เพื่อเลือกข้อความลิงก์
  110. // @description:lo ປິດການຄວບຄຸມຂອງຄລິບບີກມາ, ລືມ, ປ້ອງກັນຂໍ້ມູນ, ບໍ່ສາມາດປິດຄໍາເວລາການຄວບຄຸມ, ຄຳສັ່ງຂໍ້ມູນ, ຄຳເລືອກຂໍ້ມູນ, ຂອບເຂດປະສານຂອງຮູບພາບ, ການຮຽກຮູບຂອງຂ້ອຍແລ້ວ. ປີ້ນດີໃຫ້: Alt ເຄື່ອນຍຸກສະແດງຂ້ອຍກຳລັງເລືອກຂ້ອຍຂອງລິ້ງສຽງ.
  111. // @description:my ရိုးရှင်းမည့်နေရာများကို ဖျောက်ပြောင်းရန် ရှိနိုင်ပါသည်။ ကျေးဇူးပြု၍ စာသား ကို ကော်ပီအောင် ရှင်းမည်မဟုတ်ပါ။
  112. // @description:ka მარჯვნივ დააკლიკეთ უფლებებს, დააკოპირეთ, არჩევანის ტექსტი, მარჯვნივ კლიკის მენიუ, ტექსტის კოპირება, ტექსტის არჩევა, სურათის მარჯვნივ კლიკი და გამოწერა, დაამატეთ ფუნქციები: Alt ღილაკის დაჭერით ტექსტის არჩევა.
  113. // @description:am የቀኝ ጠቋሚውን ምቀይረህ ለማውረድ ያደረጉትን ማንኛውንም ማግኛት ሊያሳይ ይችላሉ, ቅጥ ወይም የጽሁፍ መጻፊያውን ለመርዝ ያደረጉትን ማንኛውንም ማግኛት ሊያሳይ ይችላሉ. መልክዎ ከፍተኛ ስለሆነ: Alt አውታርክ ጽሁፍ መርዝ መርጃዎን.
  114. // @description:km ដាក់អនុញ្ញាតឱ្យចុចត្រូវលើរបារអង្គចុចស្ដាប់, បិទ, ជ្រើសរើសអត្ថបទ, ម៉ឺនុយចុចស្ដាប់, ការចម្អិនអត្ថបទ, ការជ្រើសរើសអត្ថបទ, ចុចត្រូវលើរបាររូបភាព និងបន្ថែមមនុស្សពីអត្ថបទ: Alt កិច្ចការតម្រូវការចម្អិនអត្ថបទ។
  115. // ==/UserScript==
  116. (async function () {
  117. 'use strict';
  118.  
  119. const uWin = typeof unsafeWindow !== 'undefined' ? unsafeWindow : window;
  120.  
  121. if (!(uWin instanceof Window)) return;
  122.  
  123. /** @type {globalThis.PromiseConstructor} */
  124. const Promise = (async () => { })().constructor;// YouTube hacks Promise in WaterFox Classic and "Promise.resolve(0)" nevers resolve.
  125.  
  126. /** @type {() => Selection | null} */
  127. const getSelection = uWin.getSelection.bind(uWin) || Error()();
  128. /** @type {(callback: FrameRequestCallback) => number} */
  129. const requestAnimationFrame = uWin.requestAnimationFrame.bind(uWin) || Error()();
  130. /** @type {(elt: Element, pseudoElt?: string | null) => CSSStyleDeclaration} */
  131. const getComputedStyle = uWin.getComputedStyle.bind(uWin) || Error()();
  132.  
  133. const originalFocusFn = HTMLElement.prototype.focus;
  134.  
  135. let maxTrial = 16;
  136. while (!document || !document.documentElement) {
  137. await new Promise(requestAnimationFrame);
  138. if (--maxTrial < 0) return;
  139. }
  140.  
  141. const SCRIPT_TAG = "Selection and Copying Restorer (Universal)";
  142. const $nil = () => { };
  143.  
  144. let focusNotAllowedUntil = 0;
  145.  
  146. function isLatestBrowser() {
  147. let res;
  148. try {
  149. let o = { $nil };
  150. o?.$nil();
  151. o = null;
  152. o?.$nil();
  153. res = true;
  154. } catch (e) { }
  155. return !!res;
  156. }
  157. if (!isLatestBrowser()) console.warn(`${SCRIPT_TAG}: Browser version before 2020-01-01 is not recommended. Please update to the latest version.`);
  158.  
  159. function getEventListenerSupport() {
  160. if ('_b1850' in $) return $._b1850
  161. let prop = 0;
  162. document.createAttribute('z').addEventListener('nil', $nil, {
  163. get passive() {
  164. prop |= 1;
  165. },
  166. get once() {
  167. prop |= 2;
  168. }
  169. });
  170. return ($._b1850 = prop);
  171. }
  172.  
  173. function isSupportAdvancedEventListener() {
  174. return (getEventListenerSupport() & 3) === 3;
  175. }
  176.  
  177. function isSupportPassiveEventListener() {
  178. return (getEventListenerSupport() & 1) === 1;
  179. }
  180.  
  181. function inIframe() {
  182. try {
  183. return window.self !== window.top;
  184. } catch (e) {
  185. return true;
  186. }
  187. }
  188.  
  189. /*
  190. const whiteListForCustomContextMenu = [
  191. 'https://drive.google.com/',
  192. 'https://mail.google.com/',
  193. 'https://www.google.com/maps/',
  194. 'https://www.dropbox.com/',
  195. 'https://outlook.live.com/mail/'
  196. ];
  197. const isCustomContextMenuAllowedFn = () => {
  198. const href = location.href;
  199. for (h of whiteListForCustomContextMenu) {
  200. if (href.startsWith(h)) return true;
  201. }
  202. return false;
  203. }
  204. */
  205. const isCustomContextMenuAllowedFn = () => { return false; }
  206. let isCustomContextMenuAllowed = null;
  207. const $ = {
  208. utSelectionColorHack: 'msmtwejkzrqa',
  209. utTapHighlight: 'xfcklblvkjsj',
  210. utLpSelection: 'gykqyzwufxpz',
  211. utHoverBlock: 'meefgeibrtqx', // scc_emptyblock
  212. // utNonEmptyElm: 'ilkpvtsnwmjb',
  213. utNonEmptyElmPrevElm: 'jttkfplemwzo',
  214. utHoverTextWrap: 'oseksntfvucn',
  215. ksFuncReplacerCounter: '___dqzadwpujtct___',
  216. ksEventReturnValue: ' ___ndjfujndrlsx___',
  217. ksSetData: '___rgqclrdllmhr___',
  218. ksNonEmptyPlainText: '___grpvyosdjhuk___',
  219.  
  220. eh_capture_passive: () => isSupportPassiveEventListener() ? ($._eh_capture_passive = ($._eh_capture_passive || {
  221. capture: true,
  222. passive: true
  223. })) : true,
  224. eh_capture_active: () => isSupportPassiveEventListener() ? ($._eh_capture_passive = ($._eh_capture_passive || {
  225. capture: true,
  226. passive: false
  227. })) : true,
  228.  
  229. mAlert_DOWN: $nil, // dummy function in case alert replacement is not valid
  230. mAlert_UP: $nil, // dummy function in case alert replacement is not valid
  231.  
  232.  
  233. lpKeyPressing: false,
  234. lpKeyPressingPromise: Promise.resolve(),
  235.  
  236. /** @readonly */
  237. weakMapFuncReplaced: new WeakMap(),
  238. ksFuncReplacerCounterId: 0,
  239. isStackCheckForFuncReplacer: false, // multi-line stack in FireFox
  240. isGlobalEventCheckForFuncReplacer: false,
  241. enableReturnValueReplacment: false, // set true by code
  242.  
  243. /** @readonly */
  244. eyEvts: ['keydown', 'keyup', 'copy', 'contextmenu', 'select', 'selectstart', 'dragstart', 'beforecopy'], // slope: throughout
  245. delayMouseUpTasks: 0,
  246.  
  247. isNum: (d) => (d > 0 || d < 0 || d === 0),
  248.  
  249. getNodeType: (n) => ((n instanceof Node) ? n.nodeType : -1),
  250.  
  251. isAnySelection: function () {
  252. const sel = getSelection();
  253. return !sel ? null : (typeof sel.isCollapsed === 'boolean') ? !sel.isCollapsed : (sel.toString().length > 0);
  254. },
  255.  
  256. updateIsWindowEventSupported: function () {
  257. // https://developer.mozilla.org/en-US/docs/Web/API/Window/event
  258. // FireFox >= 66
  259. let p = document.createElement('noscript');
  260. p.onclick = function (ev) { $.isGlobalEventCheckForFuncReplacer = (window.event === ev) };
  261. p.dispatchEvent(new Event('click'));
  262. p = null;
  263. },
  264.  
  265. /**
  266. *
  267. * @param {string} cssStyle
  268. * @param {Node?} container
  269. * @returns
  270. */
  271. createCSSElement: function (cssStyle, container) {
  272. const css = document.createElement('style'); // slope: DOM throughout
  273. css.textContent = cssStyle;
  274. if (container) container.appendChild(css);
  275. return css;
  276. },
  277.  
  278. createFakeAlert: function (_alert) {
  279. if (typeof _alert !== 'function') return null;
  280.  
  281. function alert(msg) {
  282. alert.__isDisabled__() ? console.log("alert msg disabled: ", msg) : _alert.apply(this, arguments);
  283. };
  284. alert.toString = _alert.toString.bind(_alert);
  285. return alert;
  286. },
  287.  
  288. /**
  289. *
  290. * @param {Function} originalFunc
  291. * @param {string} pName
  292. * @returns
  293. */
  294. createFuncReplacer: function (originalFunc) {
  295. const id = ++$.ksFuncReplacerCounterId;
  296. const resFX = function (ev) {
  297. const res = originalFunc.apply(this, arguments);
  298. if (res === false) {
  299. if (!this || !ev) return false;
  300. const pName = 'on' + ev.type;
  301. const selfFunc = this[pName];
  302. if (typeof selfFunc !== 'function') return false;
  303. if (selfFunc[$.ksFuncReplacerCounter] !== id) return false;
  304. // if this is null or undefined, or this.onXXX is not this function
  305. if (ev.cancelable !== false && $.isDeactivePreventDefault(ev)) {
  306. if ($.isGlobalEventCheckForFuncReplacer === true) {
  307. if (window.event !== ev) return false; // eslint-disable-line
  308. }
  309. if ($.isStackCheckForFuncReplacer === true) {
  310. let stack = (new Error()).stack;
  311. let onlyOneLineStack = stack.indexOf('\n') === stack.lastIndexOf('\n');
  312. if (onlyOneLineStack === false) return false;
  313. }
  314. return true;
  315. }
  316. }
  317. return res;
  318. }
  319. resFX[$.ksFuncReplacerCounter] = id;
  320. resFX.toString = originalFunc.toString.bind(originalFunc);
  321. $.weakMapFuncReplaced.set(originalFunc, resFX);
  322. return resFX;
  323. },
  324.  
  325.  
  326. // listenerDisableAll: async (evt) => {
  327. // },
  328.  
  329. onceCssHighlightSelection: async () => {
  330. if (document.documentElement.hasAttribute($.utLpSelection)) return;
  331. $.onceCssHighlightSelection = null
  332. await Promise.resolve();
  333. const s = [...document.querySelectorAll('a,p,div,span,b,i,strong,li')].filter(elm => elm.childElementCount === 0); // randomly pick an element containing text only to avoid css style bug
  334. const elm = !s.length ? document.body : s[s.length >> 1];
  335. await Promise.resolve();
  336. const selectionStyle = getComputedStyle(elm, '::selection');
  337. let selectionBackgroundColor = selectionStyle.getPropertyValue('background-color');
  338. if (/^rgba\(\d+,\s*\d+,\s*\d+,\s*0\)$/.test(selectionBackgroundColor)) {
  339. document.documentElement.setAttribute($.utSelectionColorHack, "");
  340. } else {
  341. let bodyBackgroundColor = getComputedStyle(document.body).getPropertyValue('background-color');
  342. if (bodyBackgroundColor === selectionBackgroundColor) {
  343. document.documentElement.setAttribute($.utSelectionColorHack, "");
  344. }
  345. }
  346. await Promise.resolve();
  347. const elmStyle = getComputedStyle(elm);
  348. let highlightColor = elmStyle.getPropertyValue('-webkit-tap-highlight-color');
  349. if (/^rgba\(\d+,\s*\d+,\s*\d+,\s*0\)$/.test(highlightColor)) document.documentElement.setAttribute($.utTapHighlight, "");
  350. document.documentElement.setAttribute($.utTapHighlight, "");
  351. },
  352.  
  353. clipDataProcess: function (clipboardData) {
  354.  
  355. if (!clipboardData) return;
  356. const evt = clipboardData[$.ksSetData]; // NOT NULL when preventDefault is called
  357. if (!evt || evt.clipboardData !== clipboardData) return;
  358. const plainText = clipboardData[$.ksNonEmptyPlainText]; // NOT NULL when setData is called with non empty input
  359. if (!plainText) return;
  360.  
  361. // BOTH preventDefault and setData are called.
  362.  
  363. if (evt.cancelable === false || evt.defaultPrevented === true) return;
  364.  
  365.  
  366. // ---- disable text replacement on plain text node(s) ----
  367.  
  368. let cSelection = getSelection();
  369. if (!cSelection) return; // ?
  370. let exactSelectionText = cSelection.toString();
  371. let trimedSelectionText = exactSelectionText.trim();
  372. if (exactSelectionText.length > 0 && exactSelectionText.length < plainText.length) {
  373. let pSelection = trimedSelectionText.replace(/[\r\n\t\b\x20\xA0\u200b\uFEFF\u3000]+/g, '');
  374. let pRequest = plainText.replace(/[\r\n\t\b\x20\xA0\u200b\uFEFF\u3000]+/g, '');
  375. // a newline char (\n) could be generated between nodes.
  376. let search = pRequest.indexOf(pSelection);
  377. if (search >= 0 && search < (plainText.length / 2) + 1 && $.getNodeType(cSelection.anchorNode) === 3 && $.getNodeType(cSelection.focusNode) === 3) {
  378. console.log({
  379. msg: "copy event - clipboardData replacement is NOT allowed as the text node(s) is/are selected.",
  380. oldText: trimedSelectionText,
  381. newText: plainText,
  382. })
  383. return;
  384. }
  385. }
  386.  
  387. // --- allow preventDefault for text replacement ---
  388.  
  389. $.bypass = true;
  390. evt.preventDefault();
  391. $.bypass = false;
  392.  
  393. // ---- message log ----
  394.  
  395.  
  396. if (trimedSelectionText) {
  397. // there is replacement data and the selection is not empty
  398. console.log({
  399. msg: "copy event - clipboardData replacement is allowed and the selection is not empty",
  400. oldText: trimedSelectionText,
  401. newText: plainText,
  402. })
  403. } else {
  404. // there is replacement data and the selection is empty
  405. console.log({
  406. msg: "copy event - clipboardData replacement is allowed and the selection is empty",
  407. oldText: trimedSelectionText,
  408. newText: plainText,
  409. })
  410. }
  411.  
  412. },
  413.  
  414. isDeactivePreventDefault: function (evt) {
  415. if (!evt || $.bypass) return false;
  416. let j = $.eyEvts.indexOf(evt.type);
  417. const target = evt.target;
  418. switch (j) {
  419. case 6: // dragstart
  420.  
  421. if (isCustomContextMenuAllowed === null) isCustomContextMenuAllowed = isCustomContextMenuAllowedFn();
  422. if (isCustomContextMenuAllowed) return false;
  423.  
  424. if ($.enableDragging) return false;
  425. if (target instanceof Element && target.hasAttribute('draggable')) {
  426. $.enableDragging = true;
  427. return false;
  428. }
  429. // if(evt.target.hasAttribute('draggable')&&evt.target!=window.getSelection().anchorNode)return false;
  430. return true;
  431. case 3: // contextmenu
  432.  
  433. if (isCustomContextMenuAllowed === null) isCustomContextMenuAllowed = isCustomContextMenuAllowedFn();
  434. if (isCustomContextMenuAllowed) return false;
  435.  
  436. if (target instanceof Element) {
  437. switch (target.nodeName) {
  438. case 'IMG':
  439. case 'SPAN':
  440. case 'P':
  441. case 'BODY':
  442. case 'HTML':
  443. case 'A':
  444. case 'B':
  445. case 'I':
  446. case 'PRE':
  447. case 'CODE':
  448. case 'CENTER':
  449. case 'SMALL':
  450. case 'SUB':
  451. case 'SAMP':
  452. return true;
  453. case 'VIDEO':
  454. case 'AUDIO':
  455. return false;
  456. }
  457. if (target.closest('ytd-player#ytd-player')) return false;
  458. if ((target.textContent || "").trim().length === 0 && target.querySelector('video, audio')) {
  459. return false; // exclude elements like video
  460. }
  461. }
  462. return true;
  463. case -1:
  464. return false;
  465. case 0: // keydown
  466. case 1: // keyup
  467.  
  468. if (isCustomContextMenuAllowed === null) isCustomContextMenuAllowed = isCustomContextMenuAllowedFn();
  469. if (isCustomContextMenuAllowed) return false;
  470. return (evt.keyCode === 67 && (evt.ctrlKey || evt.metaKey) && !evt.altKey && !evt.shiftKey && $.isAnySelection() === true);
  471. case 2: // copy
  472.  
  473. if (isCustomContextMenuAllowed === null) isCustomContextMenuAllowed = isCustomContextMenuAllowedFn();
  474. if (isCustomContextMenuAllowed) return false;
  475.  
  476. if (!('clipboardData' in evt && 'setData' in DataTransfer.prototype)) return true; // Event oncopy not supporting clipboardData
  477. if (evt.cancelable === false || evt.defaultPrevented === true) return true;
  478.  
  479. const cd = evt.clipboardData[$.ksSetData];
  480. if (typeof WeakRef === 'function') {
  481. let obj = cd ? cd.deref() : null;
  482. if (obj && obj !== evt) return true; // in case there is a bug
  483. evt.clipboardData[$.ksSetData] = new WeakRef(evt);
  484. } else {
  485. if (cd && cd !== evt) return true; // in case there is a bug
  486. evt.clipboardData[$.ksSetData] = evt;
  487. }
  488.  
  489. $.clipDataProcess(evt.clipboardData);
  490.  
  491. return true; // preventDefault in clipDataProcess
  492.  
  493.  
  494. default:
  495. return true;
  496. }
  497. },
  498.  
  499. enableSelectClickCopy: function () {
  500.  
  501. !(function ($setData) {
  502. DataTransfer.prototype.setData = (function setData() {
  503.  
  504. if (arguments[0] === 'text/plain' && typeof arguments[1] === 'string') {
  505. if (arguments[1].trim().length > 0) {
  506. this[$.ksNonEmptyPlainText] = arguments[1]
  507. } else if (this[$.ksNonEmptyPlainText]) {
  508. arguments[1] = this[$.ksNonEmptyPlainText]
  509. }
  510. }
  511.  
  512. $.clipDataProcess(this)
  513.  
  514. let res = $setData.apply(this, arguments)
  515.  
  516. return res;
  517.  
  518. })
  519. })(DataTransfer.prototype.setData);
  520.  
  521. Object.defineProperties(DataTransfer.prototype, {
  522. [$.ksSetData]: { // store the event
  523. value: null,
  524. writable: true,
  525. enumerable: false,
  526. configurable: true
  527. },
  528. [$.ksNonEmptyPlainText]: { // store the text
  529. value: null,
  530. writable: true,
  531. enumerable: false,
  532. configurable: true
  533. }
  534. })
  535.  
  536.  
  537. Event.prototype.preventDefault = (function (f) {
  538. function preventDefault() {
  539. if (this.cancelable !== false && !$.isDeactivePreventDefault(this)) f.call(this);
  540. }
  541. preventDefault.toString = f.toString.bind(f);
  542. return preventDefault;
  543. })(Event.prototype.preventDefault);
  544.  
  545. Object.defineProperty(Event.prototype, "returnValue", {
  546. get() {
  547. return $.ksEventReturnValue in this ? this[$.ksEventReturnValue] : true;
  548. },
  549. set(newValue) {
  550. if (newValue === false) this.preventDefault();
  551. this[$.ksEventReturnValue] = newValue;
  552. },
  553. enumerable: true,
  554. configurable: true
  555. });
  556.  
  557. $.enableReturnValueReplacment = true;
  558. // for (const eyEvt of $.eyEvts) {
  559. // document.addEventListener(eyEvt, $.listenerDisableAll, true); // Capture Event; passive:false; expected occurrence COMPLETELY before Target Capture and Target Bubble
  560. // }
  561.  
  562. // userscript bug ? window.alert not working
  563. /** @type {Window | null} */
  564. let window_ = uWin;
  565. if (window_) {
  566. let _alert = window_.alert; // slope: temporary
  567. if (typeof _alert === 'function') {
  568. let _mAlert = $.createFakeAlert(_alert);
  569. if (_mAlert) {
  570. let clickBlockingTo = 0;
  571. _mAlert.__isDisabled__ = () => clickBlockingTo > +new Date;
  572. $.mAlert_DOWN = () => (clickBlockingTo = +new Date + 50);
  573. $.mAlert_UP = () => (clickBlockingTo = +new Date + 20);
  574. window_.alert = _mAlert
  575. }
  576. _mAlert = null;
  577. }
  578. _alert = null;
  579. }
  580. window_ = null;
  581.  
  582. },
  583.  
  584. lpCheckPointer: function (targetElm) {
  585. if (targetElm instanceof Element && targetElm.matches('*:hover')) {
  586. if (getComputedStyle(targetElm).getPropertyValue('cursor') === 'pointer' && targetElm.textContent) return true;
  587. }
  588. return false;
  589. },
  590.  
  591. /**
  592. *
  593. * @param {Event} evt
  594. * @param {boolean} toPreventDefault
  595. */
  596. eventCancel: function (evt, toPreventDefault) {
  597. $.bypass = true;
  598. !toPreventDefault || evt.preventDefault()
  599. evt.stopPropagation();
  600. evt.stopImmediatePropagation();
  601. $.bypass = false;
  602. },
  603.  
  604. lpHoverBlocks: [],
  605. lpKeyAltLastPressAt: 0,
  606. lpKeyAltPressInterval: 0,
  607.  
  608. noPlayingVideo: function () {
  609.  
  610. // prevent poor video preformance
  611.  
  612. let noPlaying = true;
  613. for (const video of document.querySelectorAll('video[src]')) {
  614.  
  615. if (video.paused === false) {
  616. noPlaying = false;
  617. break;
  618. }
  619.  
  620. }
  621. return noPlaying;
  622.  
  623.  
  624. },
  625.  
  626.  
  627.  
  628. /** @type {EventListener} */
  629. lpKeyDown: (evt) => {
  630.  
  631. if (!$.gm_lp_enable) return;
  632.  
  633. const isAltPress = (evt.key === "Alt" && evt.altKey && !evt.ctrlKey && !evt.metaKey && !evt.shiftKey);
  634.  
  635. if (isAltPress) {
  636.  
  637. $.lpKeyAltLastPressAt = +new Date;
  638.  
  639. let element = evt.target;
  640.  
  641.  
  642. if ($.lpKeyPressing === false && (element instanceof Node) && element.parentNode && !evt.repeat && $.noPlayingVideo()) {
  643.  
  644. $.lpKeyPressing = true;
  645.  
  646. $.cid_lpKeyPressing = setInterval(() => {
  647. if ($.lpKeyAltLastPressAt + 500 < +new Date) {
  648. $.lpCancelKeyPressAlt();
  649. }
  650. }, 137);
  651.  
  652. const rootNode = $.rootHTML(element);
  653. if (rootNode) {
  654. let tmp_wmEty = null;
  655.  
  656.  
  657. let wmTextWrap = new WeakMap();
  658.  
  659. $.lpKeyPressingPromise = $.lpKeyPressingPromise.then(() => {
  660. for (const elm of $.lpHoverBlocks) {
  661. elm.removeAttribute($.utNonEmptyElmPrevElm)
  662. elm.removeAttribute($.utHoverTextWrap)
  663. }
  664. $.lpHoverBlocks.length = 0;
  665. }).then(() => {
  666. tmp_wmEty = new WeakMap(); // 1,2,3.....: non-empty elm, -1:empty elm
  667. const s = [...rootNode.querySelectorAll('*:not(button, textarea, input, script, noscript, style, link, img, br)')].filter((elm) => elm.childElementCount === 0 && (elm.textContent || '').trim().length > 0)
  668. for (const elm of s) tmp_wmEty.set(elm, 1);
  669. return s;
  670. }).then((s) => {
  671. let laterArr = [];
  672. let promises = [];
  673.  
  674. let promiseCallback = parentNode => {
  675. if (wmTextWrap.get(parentNode) !== null) return;
  676. const m = [...parentNode.children].some(elm => {
  677. const value = getComputedStyle(elm).getPropertyValue('z-index');
  678. if (typeof value === 'string' && value.length > 0) return $.isNum(+value)
  679. return false
  680. })
  681. wmTextWrap.set(parentNode, m)
  682. if (m) {
  683. $.lpHoverBlocks.push(parentNode);
  684. parentNode.setAttribute($.utHoverTextWrap, '')
  685. }
  686.  
  687. };
  688.  
  689. for (const elm of s) {
  690. let qElm = elm;
  691. let qi = 1;
  692. while (true) {
  693. let pElm = qElm.previousElementSibling;
  694. let anyEmptyHover = false;
  695. while (pElm) {
  696. if (tmp_wmEty.get(pElm) > 0) break;
  697. if (!pElm.matches(`button, textarea, input, script, noscript, style, link, img, br`) && (pElm.textContent || '').length === 0 && pElm.clientWidth * pElm.clientHeight > 0) {
  698. laterArr.push(pElm);
  699. anyEmptyHover = true;
  700. }
  701. pElm = pElm.previousElementSibling;
  702. }
  703. if (anyEmptyHover && !wmTextWrap.has(qElm.parentNode)) {
  704. wmTextWrap.set(qElm.parentNode, null)
  705. promises.push(Promise.resolve(qElm.parentNode).then(promiseCallback))
  706. }
  707. qElm = qElm.parentNode;
  708. if (!qElm || qElm === rootNode) break;
  709. qi++
  710. if (tmp_wmEty.get(qElm) > 0) break;
  711. tmp_wmEty.set(qElm, qi)
  712. }
  713. }
  714.  
  715. tmp_wmEty = null;
  716.  
  717. Promise.all(promises).then(() => {
  718. promises.length = 0;
  719. promises = null;
  720. promiseCallback = null;
  721. for (const pElm of laterArr) {
  722. let parentNode = pElm.parentNode
  723. if (wmTextWrap.get(parentNode) === true) {
  724. $.lpHoverBlocks.push(pElm);
  725. pElm.setAttribute($.utNonEmptyElmPrevElm, '');
  726. }
  727. }
  728. laterArr.length = 0;
  729. laterArr = null;
  730. wmTextWrap = null;
  731. })
  732. })
  733.  
  734. }
  735.  
  736. }
  737.  
  738.  
  739. } else if ($.lpKeyPressing === true) {
  740.  
  741. $.lpCancelKeyPressAlt();
  742.  
  743. }
  744.  
  745. },
  746. lpCancelKeyPressAlt: () => {
  747. $.lpKeyPressing = false;
  748. if ($.cid_lpKeyPressing > 0) $.cid_lpKeyPressing = clearInterval($.cid_lpKeyPressing);
  749.  
  750. $.lpKeyPressingPromise = $.lpKeyPressingPromise.then(() => {
  751. for (const elm of $.lpHoverBlocks) {
  752. elm.removeAttribute($.utNonEmptyElmPrevElm);
  753. elm.removeAttribute($.utHoverTextWrap);
  754. }
  755. $.lpHoverBlocks.length = 0;
  756. })
  757.  
  758. setTimeout(function () {
  759. if ($.lpMouseActive === 1) {
  760. $.lpMouseUpClear();
  761. $.lpMouseActive = 0;
  762. }
  763. }, 32);
  764.  
  765. },
  766. /** @type {EventListener} */
  767. lpKeyUp: (evt) => {
  768.  
  769. if (!$.gm_lp_enable) return;
  770.  
  771. if ($.lpKeyPressing === true) {
  772. $.lpCancelKeyPressAlt();
  773. }
  774.  
  775. },
  776.  
  777. lpAltRoots: [],
  778.  
  779. /** @type {EventListener} */
  780. lpMouseDown: (evt) => {
  781.  
  782. if (!$.gm_lp_enable) return;
  783.  
  784. $.lpMouseActive = 0;
  785. if (evt.altKey && !evt.ctrlKey && !evt.metaKey && !evt.shiftKey && evt.button === 0 && (evt.target instanceof Node) && $.noPlayingVideo()) {
  786. $.lpMouseActive = 1;
  787. $.eventCancel(evt, false);
  788. const rootNode = $.rootHTML(evt.target);
  789. $.lpAltRoots.push(rootNode);
  790. rootNode.setAttribute($.utLpSelection, '');
  791. }
  792. },
  793.  
  794. lpMouseUpClear: function () {
  795. for (const rootNode of $.lpAltRoots) rootNode.removeAttribute($.utLpSelection);
  796. $.lpAltRoots.length = 0;
  797. if ($.onceCssHighlightSelection) requestAnimationFrame($.onceCssHighlightSelection);
  798. },
  799.  
  800. /** @type {EventListener} */
  801. lpMouseUp: (evt) => {
  802.  
  803. if (!$.gm_lp_enable) return;
  804.  
  805. if ($.lpMouseActive === 1) {
  806. $.lpMouseActive = 2;
  807. $.eventCancel(evt, false);
  808. $.lpMouseUpClear();
  809. }
  810. },
  811.  
  812. /** @type {EventListener} */
  813. lpClick: (evt) => {
  814.  
  815. if (!$.gm_lp_enable) return;
  816.  
  817. if ($.lpMouseActive === 2) {
  818. $.eventCancel(evt, false);
  819. }
  820. },
  821.  
  822. lpEnable: function () { // this is an optional feature for modern browser
  823. // the built-in browser feature has already disabled the default event behavior, the coding is just to ensure no "tailor-made behavior" occuring.
  824. const opt = $.eh_capture_passive();
  825. document.addEventListener('keydown', $.lpKeyDown, opt)
  826. document.addEventListener('keyup', $.lpKeyUp, opt)
  827. document.addEventListener('mousedown', $.lpMouseDown, opt)
  828. document.addEventListener('mouseup', $.lpMouseUp, opt)
  829. document.addEventListener('click', $.lpClick, opt)
  830. },
  831.  
  832. /**
  833. *
  834. * @param {Node | null} node
  835. * @returns
  836. */
  837. rootHTML: (node) => {
  838.  
  839. if (!(node instanceof Node)) return null;
  840. if (!node.ownerDocument) return node;
  841. let rootNode = node.getRootNode ? node.getRootNode() : null
  842. if (!rootNode) {
  843. let pElm = node;
  844. for (let parentNode; parentNode = pElm.parentNode;) {
  845. pElm = parentNode;
  846. }
  847. rootNode = pElm;
  848. }
  849.  
  850.  
  851. rootNode = rootNode.querySelector('html') || node.ownerDocument.documentElement || null;
  852. return rootNode
  853.  
  854. },
  855.  
  856. // note: "user-select: XXX" is deemed as invalid property value in FireFox.
  857.  
  858. injectCSSRules: () => {
  859. const cssStyleOnReady = `
  860.  
  861. html {
  862. --sac-user-select: auto;
  863. }
  864. [role="slider"], input, textarea {
  865. --sac-user-select: nil;
  866. }
  867. label:not(:empty) {
  868. --sac-user-select: auto;
  869. }
  870.  
  871. html, html *,
  872. html *[style], html *[class] {
  873. -webkit-touch-callout: default !important; -moz-user-select: var(--sac-user-select) !important; -webkit-user-select: var(--sac-user-select) !important; user-select: var(--sac-user-select) !important;
  874. }
  875.  
  876. html *:hover, html *:link, html *:visited, html *:active {
  877. -webkit-touch-callout: default !important; -moz-user-select: var(--sac-user-select) !important; -webkit-user-select: var(--sac-user-select) !important; user-select: var(--sac-user-select) !important;
  878. }
  879.  
  880. html *::before, html *::after {
  881. -webkit-touch-callout: default !important; -moz-user-select: auto !important; -webkit-user-select: auto !important; user-select: auto !important;
  882. }
  883.  
  884. *:hover>img[src]{pointer-events:auto !important;}
  885.  
  886. [${$.utSelectionColorHack}] :not(input):not(textarea)::selection{ background-color: Highlight !important; color: HighlightText !important;}
  887. [${$.utSelectionColorHack}] :not(input):not(textarea)::-moz-selection{ background-color: Highlight !important; color: HighlightText !important;}
  888. [${$.utTapHighlight}] *{ -webkit-tap-highlight-color: rgba(0, 0, 0, 0.18) !important;}
  889.  
  890. [${$.utHoverTextWrap}]>[${$.utNonEmptyElmPrevElm}]{pointer-events:none !important;}
  891. [${$.utHoverTextWrap}]>*{z-index:inherit !important;}
  892.  
  893. html[${$.utLpSelection}] *:hover, html[${$.utLpSelection}] *:hover * { cursor:text !important;}
  894. html[${$.utLpSelection}] :not(input):not(textarea)::selection {background-color: rgba(255, 156, 179, 0.5) !important;}
  895. html[${$.utLpSelection}] :not(input):not(textarea)::-moz-selection {background-color: rgba(255, 156, 179, 0.5) !important;}
  896.  
  897. img[${$.utHoverBlock}="4"]{display:none !important;}
  898. [${$.utHoverBlock}="7"]{padding:0 !important;overflow:hidden !important;}
  899. [${$.utHoverBlock}="7"]>img[${$.utHoverBlock}="4"]:first-child{
  900. display:inline-block !important;
  901. position: relative !important;
  902. top: auto !important;
  903. left: auto !important;
  904. bottom: auto !important;
  905. right: auto !important;
  906. opacity: 0 !important;
  907. padding: 0 !important;
  908. margin: 0 !important;
  909. width: 100% !important;
  910. height: 100% !important;
  911. outline: 0 !important;
  912. border: 0 !important;
  913. box-sizing: border-box !important;
  914. transform: initial !important;
  915. -moz-user-select: none !important;
  916. -webkit-user-select: none !important;
  917. user-select: none !important;
  918. z-index:1 !important;
  919. float: left !important;
  920. cursor:inherit !important;
  921. pointer-events:inherit !important;
  922. border-radius: inherit !important;
  923. background:none !important;
  924. }
  925.  
  926. `.trim();
  927. $.createCSSElement(cssStyleOnReady, document.documentElement);
  928. },
  929.  
  930. disableHoverBlock: () => {
  931.  
  932. const nMap = new WeakMap();
  933.  
  934. /**
  935. *
  936. * @param {HTMLElement} elm
  937. * @returns
  938. */
  939. function elmParam(elm) {
  940. let mElm = nMap.get(elm);
  941. if (!mElm) nMap.set(elm, mElm = {});
  942. return mElm;
  943. }
  944.  
  945. /**
  946. *
  947. * @param {DOMRect} rect1
  948. * @param {DOMRect} rect2
  949. * @returns
  950. */
  951. function overlapArea(rect1, rect2) {
  952.  
  953. let l1 = {
  954. x: rect1.left,
  955. y: rect1.top
  956. }
  957.  
  958. let r1 = {
  959. x: rect1.right,
  960. y: rect1.bottom
  961. }
  962. let l2 = {
  963. x: rect2.left,
  964. y: rect2.top
  965. }
  966.  
  967. let r2 = {
  968. x: rect2.right,
  969. y: rect2.bottom
  970. }
  971.  
  972. // Area of 1st Rectangle
  973. let area1 = Math.abs(l1.x - r1.x) * Math.abs(l1.y - r1.y);
  974.  
  975. // Area of 2nd Rectangle
  976. let area2 = Math.abs(l2.x - r2.x) * Math.abs(l2.y - r2.y);
  977.  
  978. // Length of intersecting part i.e
  979. // start from max(l1.x, l2.x) of
  980. // x-coordinate and end at min(r1.x,
  981. // r2.x) x-coordinate by subtracting
  982. // start from end we get required
  983. // lengths
  984. let x_dist = Math.min(r1.x, r2.x) - Math.max(l1.x, l2.x);
  985. let y_dist = Math.min(r1.y, r2.y) - Math.max(l1.y, l2.y);
  986. let areaI = 0;
  987. if (x_dist > 0 && y_dist > 0) {
  988. areaI = x_dist * y_dist;
  989. }
  990.  
  991. return {
  992. area1,
  993. area2,
  994. areaI
  995. };
  996.  
  997.  
  998. }
  999.  
  1000. function redirectEvent(event, toElement) {
  1001.  
  1002. toElement.dispatchEvent(new event.constructor(event.type, event));
  1003. if (event.type !== 'wheel') event.preventDefault();
  1004. event.stopPropagation();
  1005. }
  1006.  
  1007. /** @type {WeakMap<Node, number>} */
  1008. const floatingBlockHover = new WeakMap();
  1009.  
  1010. /**
  1011. @typedef NImg
  1012. @type {Object}
  1013. @property {HTMLImageElement} elm The Image Element
  1014. @property {number} lastTime lastTime
  1015. @property {number} cid_fade cid for fade
  1016.  
  1017. */
  1018.  
  1019. /** @type { NImg[] } */
  1020. let _nImgs = [];
  1021. const handleNImgs = async (img) => {
  1022. await Promise.resolve();
  1023. for (const s of _nImgs) {
  1024. if (s.elm === img) {
  1025. s.lastTime = +new Date
  1026. }
  1027. }
  1028. }
  1029.  
  1030. function nImgFunc() {
  1031.  
  1032. for (const s of _nImgs) {
  1033. if (s.lastTime + 800 < +new Date) {
  1034. s.lastTime = +new Date;
  1035. return s.elm
  1036. }
  1037. }
  1038.  
  1039. let nImg = document.createElement('img');
  1040. nImg.setAttribute('title', ' ');
  1041. nImg.setAttribute('alt', ' ');
  1042. nImg.onerror = function () {
  1043. if (this.parentNode instanceof Node) this.parentNode.removeChild(this)
  1044. }
  1045. nImg.setAttribute($.utHoverBlock, '4');
  1046. const handle = function (event) {
  1047. if (this === event.target) {
  1048. if (event.button !== 2) redirectEvent(event, this.parentNode)
  1049. handleNImgs(this);
  1050. }
  1051. }
  1052. nImg.addEventListener('click', handle, true);
  1053. nImg.addEventListener('mousedown', handle, true);
  1054. nImg.addEventListener('mouseup', handle, true);
  1055. nImg.addEventListener('mousemove', handle, true);
  1056. nImg.addEventListener('mouseover', handle, true);
  1057. nImg.addEventListener('mouseout', handle, true);
  1058. nImg.addEventListener('mouseenter', handle, true);
  1059. nImg.addEventListener('mouseleave', handle, true);
  1060. // nImg.addEventListener('wheel', handle, $.eh_capture_passive());
  1061. let resObj = {
  1062. elm: nImg,
  1063. lastTime: +new Date,
  1064. cid_fade: 0
  1065. }
  1066. _nImgs.push(resObj)
  1067.  
  1068. return nImg;
  1069.  
  1070. }
  1071.  
  1072. const wmHoverUrl = new WeakMap();
  1073. /** @type {Node | null} */
  1074. let lastMouseEnterElm = null;
  1075. let lastMouseEnterAt = 0;
  1076. let lastMouseEnterCid = 0;
  1077.  
  1078. const mouseEnter = async (evt) => {
  1079.  
  1080. if (!$.gm_disablehover_enable) return;
  1081. lastMouseEnterElm = evt.target
  1082. lastMouseEnterAt = +new Date;
  1083.  
  1084. if (lastMouseEnterCid) return;
  1085. lastMouseEnterCid = 1;
  1086. do {
  1087. await new Promise(resolve => setTimeout(resolve, 82));
  1088. } while (+new Date - lastMouseEnterAt < 30);
  1089. lastMouseEnterCid = 0;
  1090.  
  1091. // if($.lpKeyPressing)return;
  1092.  
  1093. /** @type {Node | null} */
  1094. const targetElm = lastMouseEnterElm
  1095.  
  1096. await Promise.resolve();
  1097.  
  1098. if (!targetElm || !targetElm.parentNode) {
  1099. return;
  1100. }
  1101. if (floatingBlockHover.get(targetElm)) {
  1102. let url = null
  1103. if (targetElm.getAttribute($.utHoverBlock) === '7' && (url = wmHoverUrl.get(targetElm)) && targetElm.querySelector(`[${$.utHoverBlock}]`) === null) {
  1104. let _nImg = nImgFunc();
  1105. if (_nImg.parentNode !== targetElm) {
  1106. _nImg.setAttribute('src', url);
  1107. targetElm.insertBefore(_nImg, targetElm.firstChild);
  1108. }
  1109. }
  1110. return;
  1111. }
  1112. floatingBlockHover.set(targetElm, 1);
  1113.  
  1114. await Promise.resolve();
  1115.  
  1116. if (!(targetElm instanceof Element)) return;
  1117. // if (targetElm.nodeType !== 1) return;
  1118. if ("|SVG|IMG|HTML|BODY|VIDEO|AUDIO|BR|HEAD|NOSCRIPT|SCRIPT|STYLE|TEXTAREA|AREA|INPUT|FORM|BUTTON|".indexOf(`|${targetElm.nodeName}|`) >= 0) return;
  1119.  
  1120. const targetArea = targetElm.clientWidth * targetElm.clientHeight
  1121.  
  1122. if (targetArea > 0) { } else {
  1123. return;
  1124. }
  1125.  
  1126. /** @type {string | null} */
  1127. let sUrl = null;
  1128.  
  1129. const targetCSS = getComputedStyle(targetElm)
  1130. const targetBgImage = targetCSS.getPropertyValue('background-image');
  1131. let exec1 = null
  1132.  
  1133. if (targetBgImage !== 'none' && (exec1 = /^\s*url\s*\("?([^"\)]+\b(\.gif|\.png|\.jpeg|\.jpg|\.webp)\b[^"\)]*)"?\)\s*$/i.exec(targetBgImage))) {
  1134. if ((targetElm.textContent || "").trim().length > 0) return;
  1135. const url = exec1[1];
  1136. sUrl = url;
  1137.  
  1138. // console.log(targetBgImage,[...exec1])
  1139. } else {
  1140.  
  1141.  
  1142. if (targetCSS.getPropertyValue('position') === 'absolute' && +targetCSS.getPropertyValue('z-index') > 0) { } else {
  1143. return;
  1144. }
  1145. if ((targetElm.textContent || "").trim().length > 0) return;
  1146.  
  1147. let possibleResults = [];
  1148.  
  1149. for (const imgElm of document.querySelectorAll('img[src]')) {
  1150. const param = elmParam(imgElm)
  1151. if (!param.area) {
  1152. const area = imgElm.clientWidth * imgElm.clientHeight
  1153. if (area > 0) param.area = area;
  1154. }
  1155. if (param.area > 0) {
  1156. if (targetArea > param.area * 0.9) possibleResults.push(imgElm)
  1157. }
  1158. }
  1159.  
  1160. let i = 0;
  1161. let j = 0;
  1162. for (const imgElm of possibleResults) {
  1163.  
  1164. const cmpVal = targetElm.compareDocumentPosition(imgElm)
  1165.  
  1166. /*
  1167.  
  1168. 1: The two nodes do not belong to the same document.
  1169. 2: p1 is positioned after p2.
  1170. 4: p1 is positioned before p2.
  1171. 8: p1 is positioned inside p2.
  1172. 16: p2 is positioned inside p1.
  1173. 32: The two nodes has no relationship, or they are two attributes on the same element.
  1174.  
  1175. */
  1176.  
  1177. if (cmpVal & 8 || cmpVal & 16) return;
  1178. if (cmpVal & 2) j++; // I<p
  1179. else if (cmpVal & 4) break; // I>p
  1180.  
  1181.  
  1182. i++;
  1183.  
  1184. }
  1185.  
  1186. // before: j-1 after: j
  1187.  
  1188. let indexBefore = j - 1;
  1189. let indexAfter = j;
  1190. if (indexBefore < 0) indexBefore = 0;
  1191. if (indexAfter > possibleResults.length - 1) indexAfter = possibleResults.length - 1;
  1192.  
  1193. // setTimeout(function(){
  1194. for (let i = indexBefore; i <= indexAfter; i++) {
  1195. const s = possibleResults[i];
  1196. const {
  1197. area1,
  1198. area2,
  1199. areaI
  1200. } = overlapArea(targetElm.getBoundingClientRect(), s.getBoundingClientRect())
  1201. // const criteria = area1 * 0.7
  1202. if (areaI > 0.9 * area2) {
  1203.  
  1204. sUrl = s.getAttribute('src');
  1205. break;
  1206.  
  1207. }
  1208. }
  1209. // },1000);
  1210.  
  1211. }
  1212.  
  1213.  
  1214.  
  1215.  
  1216. if (typeof sUrl !== 'string') return;
  1217.  
  1218. // console.log(targetElm, targetElm.querySelectorAll('img').length)
  1219.  
  1220. // console.log(313, evt.target, s)
  1221. let _nImg = nImgFunc();
  1222.  
  1223.  
  1224. if (_nImg.parentNode !== targetElm) {
  1225. _nImg.setAttribute('src', sUrl);
  1226. targetElm.insertBefore(_nImg, targetElm.firstChild);
  1227. wmHoverUrl.set(targetElm, sUrl);
  1228. targetElm.setAttribute($.utHoverBlock, '7');
  1229. }
  1230.  
  1231.  
  1232.  
  1233. }
  1234.  
  1235. document.addEventListener('mouseenter', mouseEnter, $.eh_capture_passive())
  1236.  
  1237.  
  1238.  
  1239. },
  1240.  
  1241. /** @type {EventListener} */
  1242. acrAuxDown: (evt) => {
  1243.  
  1244. if (!$.gm_prevent_aux_click_enable) return;
  1245.  
  1246. if (evt.button === 1) {
  1247. let check = $.dmmMouseUpLast > $.dmmMouseDownLast && evt.timeStamp - $.dmmMouseUpLast < 40
  1248. $.dmmMouseDownLast = evt.timeStamp;
  1249. if (check) {
  1250. $.eventCancel(evt, true);
  1251. }
  1252. }
  1253.  
  1254. },
  1255.  
  1256. /** @type {EventListener} */
  1257. acrAuxUp: (evt) => {
  1258. if (!$.gm_prevent_aux_click_enable) return;
  1259.  
  1260. if (evt.button === 1) {
  1261. let check = $.dmmMouseDownLast > $.dmmMouseUpLast && evt.timeStamp - $.dmmMouseDownLast < 40;
  1262. $.dmmMouseUpLast = evt.timeStamp;
  1263. if (check) {
  1264. $.dmmMouseUpCancel = evt.timeStamp;
  1265. $.eventCancel(evt, true);
  1266. }
  1267. }
  1268.  
  1269. },
  1270.  
  1271.  
  1272. /** @type {EventListener} */
  1273. acrAuxClick: (evt) => {
  1274. if (!$.gm_prevent_aux_click_enable) return;
  1275.  
  1276. if (evt.button === 1) {
  1277. if (evt.timeStamp - $.dmmMouseUpCancel < 40) {
  1278. $.eventCancel(evt, true);
  1279. }
  1280. }
  1281.  
  1282.  
  1283. },
  1284.  
  1285. // preventAuxClickRepeat: function () {
  1286.  
  1287. // const opt = $.eh_capture_active();
  1288. // // document.addEventListener('mousedown', $.acrAuxDown, opt)
  1289. // // document.addEventListener('mouseup', $.acrAuxUp, opt)
  1290. // document.addEventListener('auxclick', $.acrAuxClick, opt)
  1291.  
  1292.  
  1293. // },
  1294.  
  1295. mousedownFocus: (evt) => {
  1296. focusNotAllowedUntil = Date.now() + 4;
  1297. },
  1298.  
  1299. mouseupFocus: (evt) => {
  1300. focusNotAllowedUntil = 0;
  1301. },
  1302.  
  1303. MenuEnable: (
  1304. class MenuEnable {
  1305.  
  1306. /**
  1307. *
  1308. * @param {string} textToEnable
  1309. * @param {string} textToDisable
  1310. * @param {Function} callback
  1311. * @param {boolean?} initalEnable
  1312. */
  1313. constructor(textToEnable, textToDisable, callback, initalEnable) {
  1314. /** @type {number|string|null} */
  1315. this.h = null;
  1316. /** @type {string} */
  1317. this.textToEnable = textToEnable;
  1318. /** @type {string} */
  1319. this.textToDisable = textToDisable;
  1320. /** @type {Function} */
  1321. this.callback = callback;
  1322. /** @type {Function} */
  1323. this.gx = this.gx.bind(this);
  1324. }
  1325.  
  1326. unregister() {
  1327. (this.h !== null) ? (GM_unregisterMenuCommand(this.h), (this.h = null)) : null;
  1328. }
  1329.  
  1330. register(text) {
  1331. if (typeof text === 'string') this.showText = text;
  1332. text = this.showText;
  1333. if (typeof text !== 'string') return;
  1334. this.h = GM_registerMenuCommand(text, this.gx);
  1335. }
  1336.  
  1337. a(o) {
  1338.  
  1339. if (this.enabled === o.bEnable) return;
  1340. this.enabled = o.bEnable;
  1341. this.unregister();
  1342.  
  1343.  
  1344. let pr = 0;
  1345.  
  1346. if ($.gm_status_fn_store && $.gm_status_fn_store.indexOf(this) >= 0) {
  1347.  
  1348. let store = $.gm_status_fn_store
  1349. let idx = store.indexOf(this)
  1350. let count = store.length;
  1351.  
  1352.  
  1353. if (idx >= 0 && idx <= count - 2) {
  1354.  
  1355. // console.log(idx, count)
  1356.  
  1357. for (let jdx = idx + 1; jdx < count; jdx++) {
  1358.  
  1359. store[jdx].unregister();
  1360. }
  1361.  
  1362. this.register(o.bText);
  1363.  
  1364. for (let jdx = idx + 1; jdx < count; jdx++) {
  1365.  
  1366. store[jdx].register();
  1367. }
  1368.  
  1369. pr = 1;
  1370.  
  1371. }
  1372.  
  1373.  
  1374. }
  1375.  
  1376. if (!pr) this.register(o.bText);
  1377.  
  1378. this.callback(this.enabled, o.byUserInput);
  1379.  
  1380.  
  1381. }
  1382.  
  1383. enableNow(byUserInput) {
  1384. this.a({
  1385. bEnable: true,
  1386. bText: this.textToDisable,
  1387. byUserInput
  1388. });
  1389.  
  1390. }
  1391.  
  1392. gx() {
  1393. if (this.enabled) this.disableNow(true);
  1394. else this.enableNow(true);
  1395.  
  1396. }
  1397.  
  1398. disableNow(byUserInput) {
  1399. this.a({
  1400. bEnable: false,
  1401. bText: this.textToEnable,
  1402. byUserInput
  1403. });
  1404.  
  1405. }
  1406.  
  1407. toggle(enable, byUserInput) {
  1408. enable ? this.enableNow(byUserInput) : this.disableNow(byUserInput);
  1409. }
  1410.  
  1411. }
  1412. ),
  1413.  
  1414. /**
  1415. *
  1416. * @param {string} gm_name
  1417. * @param {string} textToEnable
  1418. * @param {string} textToDisable
  1419. * @param {Function} callback
  1420. */
  1421. gm_status_fn: async function (gm_name, textToEnable, textToDisable, callback) {
  1422.  
  1423. const menuEnableName = gm_name + "$menuEnable";
  1424.  
  1425. function set_gm(enabled) {
  1426. $[gm_name] = enabled;
  1427. const menuEnable = $[menuEnableName];
  1428. if (menuEnable) {
  1429. menuEnable.toggle(enabled)
  1430. };
  1431. callback(enabled)
  1432. }
  1433.  
  1434. const gmValue = await GM.getValue(gm_name, false);
  1435. set_gm(!!gmValue);
  1436.  
  1437. GM_addValueChangeListener(gm_name, function (name, old_value, new_value, remote) {
  1438.  
  1439. if (old_value === new_value || new_value === $[gm_name]) return;
  1440. set_gm(new_value);
  1441.  
  1442. });
  1443.  
  1444. if (!inIframe()) {
  1445.  
  1446. $.gm_status_fn_store = $.gm_status_fn_store || [];
  1447.  
  1448. $[menuEnableName] = new $.MenuEnable(textToEnable, textToDisable, (enabled) => {
  1449. GM.setValue(gm_name, !!enabled);
  1450. });
  1451.  
  1452. $.gm_status_fn_store.push($[menuEnableName]);
  1453.  
  1454. const gmValue = await GM.getValue(gm_name, false);
  1455. $[menuEnableName].toggle(!!gmValue);
  1456.  
  1457. }
  1458.  
  1459. },
  1460.  
  1461. /** @type {EventListener} */
  1462. genericEventHandlerLevel2: (evt) => {
  1463. if ($.gm_absolute_mode) {
  1464. // inspired by https://gf.qytechs.cn/en/scripts/23772-absolute-enable-right-click-copy
  1465. evt.stopPropagation();
  1466. evt.stopImmediatePropagation();
  1467. }
  1468. // .. and more
  1469.  
  1470. const evtType = (evt || 0).type
  1471.  
  1472. if (evtType && $.enableReturnValueReplacment === true) {
  1473. // $.listenerDisableAll(evt);
  1474. let elmNode = evt.target;
  1475. const pName = 'on' + evtType;
  1476. let maxN = 99;
  1477. while (elmNode instanceof Node) { // i.e. HTMLDocument or HTMLElement
  1478. if (--maxN < 4) break; // prevent unknown case
  1479. const f = elmNode[pName];
  1480. if (typeof f === 'function') {
  1481. let replacerId = f[$.ksFuncReplacerCounter];
  1482. if (replacerId > 0) break; // assume all parent functions are replaced; for performance only
  1483. // note: "return false" is preventDefault() in VanillaJS but preventDefault()+stopPropagation() in jQuery.
  1484. elmNode[pName] = $.weakMapFuncReplaced.get(f) || $.createFuncReplacer(f);
  1485. }
  1486. elmNode = elmNode.parentNode;
  1487. }
  1488. }
  1489.  
  1490. if (evtType === 'contextmenu') {
  1491. if (evt.defaultPrevented !== true) {
  1492. $.mainListenerPress(evt);
  1493. }
  1494. }
  1495.  
  1496. },
  1497.  
  1498. /** @type {EventListener} */
  1499. genericEventHandlerLevel1: (evt) => {
  1500. if ($.gm_absolute_mode) {
  1501. // inspired by https://gf.qytechs.cn/en/scripts/23772-absolute-enable-right-click-copy
  1502. evt.stopPropagation();
  1503. evt.stopImmediatePropagation();
  1504. }
  1505. const evtType = (evt || 0).type
  1506. if (evtType === 'mousedown') {
  1507. $.mousedownFocus(evt);
  1508. $.acrAuxDown(evt);
  1509. if (evt.defaultPrevented !== true) {
  1510. $.mainListenerPress(evt);
  1511. }
  1512. } else if (evtType === 'mouseup') {
  1513. $.mouseupFocus(evt);
  1514. $.acrAuxUp(evt);
  1515. if (evt.defaultPrevented !== true) {
  1516. $.mainListenerRelease(evt);
  1517. }
  1518. }
  1519. },
  1520.  
  1521. eventsInjection: function () {
  1522. for (const s of ['keydown', 'keyup', 'copy', 'contextmenu', 'select', 'selectstart', 'dragstart', 'beforecopy']) {
  1523. document.addEventListener(s, $.genericEventHandlerLevel2, true);
  1524. }
  1525.  
  1526. for (const s of ['cut', 'paste', 'mouseup', 'mousedown', 'drag', 'select']) {
  1527. document.addEventListener(s, $.genericEventHandlerLevel1, true);
  1528. }
  1529.  
  1530. document.addEventListener('auxclick', $.acrAuxClick, true)
  1531. },
  1532.  
  1533. delayMouseUpTasksHandler: () => {
  1534. if ($.delayMouseUpTasks > 0) {
  1535. const flag = $.delayMouseUpTasks
  1536. $.delayMouseUpTasks = 0;
  1537. if ((flag & 1) === 1) $.mAlert_UP();
  1538. if ((flag & 2) === 2 && $.enableDragging === true) $.enableDragging = false;
  1539. }
  1540. },
  1541.  
  1542. mainListenerPress: (evt) => { // Capture Event; (mousedown - desktop; contextmenu - desktop&mobile)
  1543. // $.holdingElm=evt.target;
  1544. // console.log('down',evt.target)
  1545. if ($.onceCssHighlightSelection) requestAnimationFrame($.onceCssHighlightSelection);
  1546. const isContextMenuEvent = evt.type === "contextmenu";
  1547. if (evt.button === 2 || isContextMenuEvent) $.mAlert_DOWN();
  1548. if (isContextMenuEvent && $.delayMouseUpTasks === 0) {
  1549. $.delayMouseUpTasks |= 1;
  1550. requestAnimationFrame($.delayMouseUpTasksHandler)
  1551. }
  1552. },
  1553.  
  1554. mainListenerRelease: (evt) => { // Capture Event; (mouseup - desktop)
  1555. // $.holdingElm=null;
  1556. // console.log('up',evt.target)
  1557. if ($.delayMouseUpTasks === 0) { // skip if it is already queued
  1558. if (evt.button === 2) $.delayMouseUpTasks |= 1;
  1559. if ($.enableDragging === true) $.delayMouseUpTasks |= 2;
  1560. if ($.delayMouseUpTasks > 0) {
  1561. requestAnimationFrame($.delayMouseUpTasksHandler)
  1562. }
  1563. }
  1564. }
  1565.  
  1566.  
  1567. }
  1568.  
  1569. // $.holdingElm=null;
  1570. $.eventsInjection();
  1571. $.enableSelectClickCopy()
  1572. $.injectCSSRules();
  1573.  
  1574. if (isSupportAdvancedEventListener()) $.lpEnable(); // top capture event for alt-click
  1575.  
  1576. $.disableHoverBlock();
  1577. // $.preventAuxClickRepeat();
  1578.  
  1579. console.log(`userscript running - ${SCRIPT_TAG}`);
  1580.  
  1581. $.updateIsWindowEventSupported();
  1582.  
  1583. if (typeof GM_registerMenuCommand === 'function' && typeof GM_unregisterMenuCommand === 'function') {
  1584.  
  1585. if (isSupportAdvancedEventListener()) {
  1586. $.gm_status_fn("gm_lp_enable", "To Enable `Enhanced build-in Alt Text Selection`", "To Disable `Enhanced build-in Alt Text Selection`", () => {
  1587. // callback
  1588. });
  1589. }
  1590. $.gm_status_fn("gm_disablehover_enable", "To Enable `Hover on Image`", "To Disable `Hover on Image`", () => {
  1591. // callback
  1592. });
  1593. $.gm_status_fn("gm_prevent_aux_click_enable", "To Enable `Repetitive AuxClick Prevention`", "To Disable `Repetitive AuxClick Prevention`", () => {
  1594. // callback
  1595. });
  1596. $.gm_status_fn("gm_absolute_mode", "To Enable `Absolute Mode`", "To Disable `Absolute Mode`", () => {
  1597. // callback
  1598. });
  1599.  
  1600. $.gm_status_fn("gm_remain_focus_on_mousedown", "To Enable `Remain Focus On MouseDown`", "To Disable `Remain Focus On MouseDown`", () => {
  1601. $.gm_remain_focus_on_mousedown = 0;
  1602. // callback
  1603. });
  1604.  
  1605. }
  1606.  
  1607. if (typeof originalFocusFn === 'function' && HTMLElement.prototype.focus === originalFocusFn && originalFocusFn.length === 0) {
  1608. const f = HTMLElement.prototype.focus = function () {
  1609. if (focusNotAllowedUntil && $.gm_remain_focus_on_mousedown && focusNotAllowedUntil > Date.now()) return;
  1610. return originalFocusFn.apply(this, arguments);
  1611. }
  1612. f.toString = originalFocusFn.toString.bind(originalFocusFn);
  1613. }
  1614.  
  1615.  
  1616. })();

QingJ © 2025

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