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

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

当前为 2024-01-08 提交的版本,查看 最新版本

  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.18.1.5
  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://greasyfork.org/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://vscode.dev/*
  16. // @exclude https://www.photopea.com/*
  17. // @exclude https://docs.google.com/*
  18. // @exclude https://drive.google.com/*
  19. // @exclude https://mail.google.com/*
  20. // @exclude https://www.google.com/maps/*
  21. // @exclude https://www.dropbox.com/*
  22. // @exclude https://outlook.live.com/mail/*
  23. // @exclude https://www.photopea.com/*
  24. // @exclude https://www.terabox.com/*
  25. // @exclude https://codi.link/*
  26. // @exclude https://leetcode.cn/*
  27. // @icon https://github.com/cyfung1031/userscript-supports/raw/main/icons/selection-copier.png
  28. // @grant GM_registerMenuCommand
  29. // @grant GM_unregisterMenuCommand
  30. // @grant GM.setValue
  31. // @grant GM.getValue
  32. // @grant GM_addValueChangeListener
  33. // @grant unsafeWindow
  34. // @inject-into page
  35.  
  36. // @compatible firefox Violentmonkey
  37. // @compatible firefox Tampermonkey
  38. // @compatible chrome Violentmonkey
  39. // @compatible chrome Tampermonkey
  40. // @compatible opera Violentmonkey
  41. // @compatible opera Tampermonkey
  42. // @compatible safari Stay
  43. // @compatible edge Violentmonkey
  44. // @compatible edge Tampermonkey
  45. // @compatible brave Violentmonkey
  46. // @compatible brave Tampermonkey
  47.  
  48. // @description:zh-TW 破解鎖右鍵,解除禁止復制、剪切、選擇文本、右鍵菜單、文字複製、文字選取、圖片右鍵等限制。增強功能:Alt鍵超連結文字選取。
  49. // @description:zh-CN 破解锁右键,解除禁止复制、剪切、选择文本、右键菜单、文字复制、文字选取、图片右键等限制。增强功能:Alt键超连结文字选取。
  50.  
  51. // @description:ja 右クリックを解除し、コピー、切り取り、テキスト選択、コンテキストメニュー、テキストのコピー、テキストの選択、画像の右クリックなどの制限を解除します。機能の強化:Altキーでハイパーリンクテキストの選択ができます。
  52. // @description:ko 우클릭 잠금 해제, 복사, 잘라내기, 텍스트 선택, 컨텍스트 메뉴, 텍스트 복사, 텍스트 선택, 이미지 우클릭 등의 제한을 해제합니다. 기능 강화: Alt 키로 하이퍼링크 텍스트 선택.
  53. // @description:ru Взломать запрет правой кнопкой мыши, снять ограничения на копирование, вырезание, выбор текста, контекстное меню, копирование текста, выбор текста, правая кнопка мыши на изображении и т.д. Усиление функций: выбор текста гиперссылки с помощью клавиши Alt.
  54. // @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.
  55. // @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.
  56. // @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.
  57. // @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.
  58. // @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.
  59. // @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.
  60. // @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.
  61. // @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.
  62. // @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.
  63. // @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.
  64. // @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.
  65. // @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.
  66. // @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.
  67. // @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.
  68. // @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.
  69. // @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.
  70. // @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
  71. // @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.
  72. // @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.
  73. // @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.
  74. // @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.
  75. // @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.
  76. // @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.
  77. // @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.
  78. // @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.
  79. // @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.
  80. // @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.
  81. // @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.
  82. // @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.
  83. // @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.
  84. // @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.
  85. // @description:sr Одкључајте десни клик, уклоните ограничења за копирање, исецање, избор текста, десни клик мени, копирање текста, избор текста, десни клик на слици итд. Побољшане функције: Изаберите текст хипервезе притиском на тастер Alt.
  86. // @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ä.
  87. // @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.
  88. // @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.
  89. // @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.
  90. // @description:be Разблакаваць правы клік, скасаваць абмежаванні па капіраванні, выразі, выбару тэксту, кантэкстнага меню, капіравання тэксту, выбару тэксту, правага кліку на малюнку і г. д. Пашыраныя функцыі: Выберыце тэкст гіперспасылкі з дапамогай клавішы Alt.
  91. // @description:bg Разкодирайте десен бутон, премахнете ограниченията за копиране, изрязване, избор на текст, контекстно меню, копиране на текст, избор на текст, десен бутон върху изображение и т.н. Подобрени функции: Избор на текст на хипервръзка с бутона Alt.
  92. // @description:ky Оң жаңыкты ачыңыз, көчүрмө, тандоо тексти, оң кликтык меню, текстти көчүрүү, тексти тандаңыз, сүрөттө оң кликтүү боюнча чеделерди алыңыз ж.б. Коюлу функциялар: Alt түймөсү боюнча желек текстти тандаңыз.
  93. // @description:kk Оң басқару түймесін ашыңыз, көшіру, мәтінді таңдау, оң баспас меню, мәтінді көшіру, мәтінді таңдау, суретте оң баспас еткізу ж.б. шектіліктерді алыңыз. Дайындауларды жеткізіңіз: Alt түймесімен қосымша түймен текстті таңдаңыз.
  94. // @description:mk Отклучете го десниот клик, отстрани ограничувања за копирање, исечење, избор на текст, десни клик мени, копирање на текст, избор на текст, десен клик на слика итн. Подобрување на функциите: Изберете текст на хиперлинк со копчето Alt.
  95. // @description:mn Зүүн дараалжаа сэргээх, хуулах, текст сонгох, зүүн дараалжын цэс, текст хуулах, текст сонгох, зураг дээр зүүн дараахыг сонгох гэх мэт хязгаарыг цуцлах. Үйлдэл нэмэх: Alt товчлуур ашиглан холбоосын текстээ сонгоно уу.
  96. // @description:uk Розблокуйте правий клік, видаліть обмеження щодо копіювання, вирізання, вибору тексту, контекстного меню, копіювання тексту, вибору тексту, правий клік на зображенні тощо. Покращені функції: Вибір тексту гіперпосилання за допомогою клавіші Alt.
  97. // @description:el Ξεκλειδώστε το δεξί κλικ, καταργήστε τους περιορισμούς αντιγραφής, αποκοπής, επιλογής κειμένου, μενού δεξιού κλικ, αντιγραφής κειμένου, επιλογής κειμένου, δεξί κλικ σε εικόνα κ.λπ. Βελτιωμένες λειτουργίες: Επιλογή κειμένου υπερσυνδέσμου με το πλήκτρο Alt.
  98. // @description:hy Բացեք աջ կոճակը, հանեք պահեստավորումները ֆայլի պատճենում, նշումը, տեքստի ընտրությունը, աջ կոճակի մենյուում, տեքստի պատճենումը, տեքստի ընտրությունը, աջ կոճակ պատկերի վրա և այլն: Մասնակցային ֆունկցիաների ընդհանուրավորում. Նշեք հիպերհղման տեքստը Alt ստեղնով:
  99. // @description:ur دائیں کلک کھولیں، کاپی، کٹ، متن منتخب کریں، دائیں کلک مینو، متن کاپی، متن منتخب کریں، تصویر پر دائیں کلک وغیرہ کی پابندیوں کو ختم کریں۔ تازہ کاری شدہ خصوصیات: Alt کلید کے ساتھ ہائپر لنک متن کا انتخاب کریں۔
  100. // @description:ar فتح النقرة اليمنى ، إزالة قيود النسخ ، القص ، اختيار النص ، قائمة النقرة اليمنى ، نسخ النص ، اختيار النص ، نقرة يمنى على الصورة ، وما إلى ذلك. تعزيز الوظائف: حدد نص الارتباط باستخدام مفتاح Alt.
  101. // @description:fa باز کردن کلیک راست ، برداشتن محدودیت های کپی ، برش ، انتخاب متن ، منوی کلیک راست ، کپی متن ، انتخاب متن ، کلیک راست بر روی تصویر و غیره. تقویت ویژگی ها: انتخاب متن پیوند با کلید Alt.
  102. // @description:ne दायाँ क्लिक खोल्नुहोस्, प्रतिलिपि, काट, पाठ चयन गर्नुहोस्, दायाँ क्लिक मेनु, पाठ प्रतिलिपि, पाठ चयन, तस्वीरमा दायाँ क्लिक, आदिको सीमाहरू हटाउनुहोस्। सुधारिएका सुविधाहरू: एल्ट बटनसहित हायपरलिंक पाठ छान्नुहोस्।
  103. // @description:mr उजवा क्लिक अनलॉक करा, प्रतिलिपि, कट, मजकूर निवडा, उजवा क्लिक मेनू, मजकूर प्रतिलिपि, मजकूर निवडा, प्रतिमेवर उजवा क्लिक इत्यादी सीमांकन काढा. सुधारित क्षमता: आल्ट की बटणाच्या मदतीने हायपरलिंकमधील मजकूर निवडा.
  104. // @description:hi दायीं क्लिक अनलॉक करें, प्रतिलिपि, कट, पाठ चयन करें, दायीं क्लिक मेन्यू, पाठ प्रतिलिपि, पाठ चयन, छवि पर दायीं क्लिक इत्यादि प्रतिबंधों को हटाएँ। सुधारित सुविधाएं: एल्ट कुंजी के साथ हाइपरलिंक पाठ चयन करें।
  105. // @description:as সোণা ক্লিক আনলক কৰক, প্ৰতিলিপি কৰক, কেটা কৰক, পাঠ বাছনি কৰক, সোণা ক্লিক মেনু, পাঠৰ প্ৰতিলিপি কৰক, পাঠ বাছনি কৰক, ছবিৰ সোণা ক্লিক আদিক। উন্নত সুবিধাসমূহ: আল্ট বুটামটো সহ হাইপাৰলিংকৰ পাঠ বাছনি কৰক।
  106. // @description:bn ডান ক্লিক আনলক করুন, কপি, কাট, পাঠ নির্বাচন করুন, ডান ক্লিক মেনু, পাঠ কপি, পাঠ নির্বাচন, চিত্রে ডান ক্লিক ইত্যাদি সীমাবদ্ধতা অপসারণ করুন। উন্নত বৈশিষ্ট্যগুলি: এল্ট বাটন সহ হাইপারলিংক পাঠ নির্বাচন করুন।
  107. // @description:pa ਸੱਜਾ ਕਲਿੱਕ ਖੋਲੋ, ਪਾਉਣੀ, ਕੱਟੋ, ਲਿਖਤ ਚੁਣੋ, ਸੱਜਾ ਕਲਿੱਕ ਮੀਨੂ, ਲਿਖਤ ਪਾਉਣੀ, ਲਿਖਤ ਚੁਣੋ, ਚਿੱਤਰ 'ਤੇ ਸੱਜਾ ਕਲਿੱਕ ਵਗੈਰਹ ਪਾਬੰਦੀਆਂ ਹਟਾਓ। ਸੁਧਾਰਿਤ ਫੀਚਰਾਂ: ਐਲਟ ਬਟਨ ਨਾਲ ਹਾਇਪਰਲਿੰਕ ਦੀ ਲਿਖਤ ਚੋਣ ਕਰੋ।
  108. // @description:gu જમણી ક્લિક ખોલો, કૉપિ, કાપો, ટેક્સ્ટ પસંદ કરો, જમણી ક્લિક મેનૂ, ટેક્સ્ટ કૉપિ, ટેક્સ્ટ પસંદ, ચિત્ર પર જમણી ક્લિક વગેરે પાબંધીઓ કાઢો. સુધારેલી વૈશિષ્ટ્યો: એલ્ટ બટન સાથે હાયપરલિંકના ટેક્સ્ટ પસંદ કરો.
  109. // @description:or ଡାହାଣହାତରେ ଖୋଲନ୍ତୁ, କପି କରିବା, କଟି କରିବା, ପାଠବାରେ ଚୟନ କରିବା, ଡାହାଣହାତ ମେନୁ, ପାଠବା ଏବଂ ଚିତ୍ର ଡାହାଣହାତ ପାଠ ଚୟନର ମର୍ମ୍ମ କେତେଟେ ପାରିବେ ବିବରଣୀ ମିଳିବା: ଅଲ୍ଟ କୀ ହେଇଲା ହାଇପରଲିଙ୍କ ପାଠ ଚୟନ।
  110. // @description:ta வலப்பதிவு மூலம் தடைகளை நீக்குங்கள், நகலைப் பட்டைக்கு மாற்றுங்கள், உரையை தேர்வு செய்யுங்கள், வலப்பதிவு மெனு, உரை நகலைப் படக்குகள், உரை தேர்வுகளைப் படக்குகள், பட வலப்பதிவுகள் போன்ற வரைபடங்களின் வரைபடத்தை அதிகரித்துக்கொள்ளுங்கள். அதிகப்படியான செயல்பாடு: அல்ட் விசை அடைவு உரை தேர்வு.
  111. // @description:te డౌన్‌లోడ్ చేయడానికి రైట్ క్లిక్ ని అనుమతించండి, నకలు, కట్, వచ్చేయి, కుడిచేయండి, టెక్స్ట్ నకలుచేయండి, చిత్రం రైట్ క్లిక్ చేయండి, అదనపు కొంత క్షేత్రాలను మెరుగుపరచండి: అల్ట్ కీ హైపర్‌లింక్ టెక్స్ట్ ఎంపికను పెంచుతుంది.
  112. // @description:kn ಬಲ ಕ್ಲಿಕ್ ಬಿರುದುಗಳನ್ನು ತೆರೆಯಲು ಅನುಮತಿಸುವುದು, ನಕಲು, ಕಟ್ಟು, ಆಯ್ಕೆ ಮಾಡುವುದು, ಬಲ ಕ್ಲಿಕ್ ಮೆನು, ಪಠ್ಯ ನಕಲು, ಪಠ್ಯ ಆಯ್ಕೆ, ಚಿತ್ರ ಬಲ ಕ್ಲಿಕ್ ಮುಂತಾದ ಮಿತಿಗಳನ್ನು ತೆಗೆದುಹಾಕಿ. ಪ್ರಭಾವವನ್ನು ಹೆಚ್ಚಿಸುವುದು: Alt ಕೀ ಹೈಪರ್‌ಲಿಂಕ್ ಪಠ್ಯ ಆಯ್ಕೆ.
  113. // @description:ml വലത് ക്ലിക്ക് അനുവദനീയമാക്കുക, പകരം പകർത്തുക, ടെക്സ്റ്റ് തിരിച്ചുവയ്ക്കുക, റൈറ്റ്-ക്ലിക്ക് മെനു, ടെക്സ്റ്റ് പകർത്തൽ, ടെക്സ്റ്റ് തിരിച്ചൽ, ചിത്രം റൈറ്റ്-ക്ലിക്ക് എന്നിവ നീക്കംചെയ്യുക. പ്രവർത്തനം വരുത്തുക: Alt കീ ഹൈപർലിങ്ക് ടെക്സ്റ്റ് തിരിച്ചൽ.
  114. // @description:si දකුණු ක්ලික් කරන්න ඉඩ දෙන්න, පිටුව පිරවීම, පෙළ තෝරාගන්නවා, දකුණු ක්ලික් මෙනුව, පෙළ පිරවීම, පෙළ තෝරාගන්න, පින්තුර දකුණු ක්ලික් කරන්න ඇති සීමාවෙන් සහාය ලෙස වැහියාව ඇති ක්ලික් විශේෂිත: Alt යතුර හයිපර්ලින්ක් පෙළ තෝරාගන්න.
  115. // @description:th ปลดล็อกคลิกขวาเพื่อย้าย, ย้าย, เลือกข้อความ, เมนูคลิกขวา, คัดลอกข้อความ, เลือกข้อความ, คลิกขวาภาพ และเพิ่มฟังก์ชัน: คีย์ Alt เพื่อเลือกข้อความลิงก์
  116. // @description:lo ປິດການຄວບຄຸມຂອງຄລິບບີກມາ, ລືມ, ປ້ອງກັນຂໍ້ມູນ, ບໍ່ສາມາດປິດຄໍາເວລາການຄວບຄຸມ, ຄຳສັ່ງຂໍ້ມູນ, ຄຳເລືອກຂໍ້ມູນ, ຂອບເຂດປະສານຂອງຮູບພາບ, ການຮຽກຮູບຂອງຂ້ອຍແລ້ວ. ປີ້ນດີໃຫ້: Alt ເຄື່ອນຍຸກສະແດງຂ້ອຍກຳລັງເລືອກຂ້ອຍຂອງລິ້ງສຽງ.
  117. // @description:my ရိုးရှင်းမည့်နေရာများကို ဖျောက်ပြောင်းရန် ရှိနိုင်ပါသည်။ ကျေးဇူးပြု၍ စာသား ကို ကော်ပီအောင် ရှင်းမည်မဟုတ်ပါ။
  118. // @description:ka მარჯვნივ დააკლიკეთ უფლებებს, დააკოპირეთ, არჩევანის ტექსტი, მარჯვნივ კლიკის მენიუ, ტექსტის კოპირება, ტექსტის არჩევა, სურათის მარჯვნივ კლიკი და გამოწერა, დაამატეთ ფუნქციები: Alt ღილაკის დაჭერით ტექსტის არჩევა.
  119. // @description:am የቀኝ ጠቋሚውን ምቀይረህ ለማውረድ ያደረጉትን ማንኛውንም ማግኛት ሊያሳይ ይችላሉ, ቅጥ ወይም የጽሁፍ መጻፊያውን ለመርዝ ያደረጉትን ማንኛውንም ማግኛት ሊያሳይ ይችላሉ. መልክዎ ከፍተኛ ስለሆነ: Alt አውታርክ ጽሁፍ መርዝ መርጃዎን.
  120. // @description:km ដាក់អនុញ្ញាតឱ្យចុចត្រូវលើរបារអង្គចុចស្ដាប់, បិទ, ជ្រើសរើសអត្ថបទ, ម៉ឺនុយចុចស្ដាប់, ការចម្អិនអត្ថបទ, ការជ្រើសរើសអត្ថបទ, ចុចត្រូវលើរបាររូបភាព និងបន្ថែមមនុស្សពីអត្ថបទ: Alt កិច្ចការតម្រូវការចម្អិនអត្ថបទ។
  121. // ==/UserScript==
  122. (async function () {
  123. 'use strict';
  124.  
  125. const uWin = typeof unsafeWindow !== 'undefined' ? unsafeWindow : window;
  126.  
  127. if (!(uWin instanceof Window)) return;
  128.  
  129. /** @type {globalThis.PromiseConstructor} */
  130. const Promise = (async () => { })().constructor;// YouTube hacks Promise in WaterFox Classic and "Promise.resolve(0)" nevers resolve.
  131.  
  132. /** @type {() => Selection | null} */
  133. const getSelection = uWin.getSelection.bind(uWin) || Error()();
  134. /** @type {(callback: FrameRequestCallback) => number} */
  135. const requestAnimationFrame = uWin.requestAnimationFrame.bind(uWin) || Error()();
  136. /** @type {(elt: Element, pseudoElt?: string | null) => CSSStyleDeclaration} */
  137. const getComputedStyle = uWin.getComputedStyle.bind(uWin) || Error()();
  138.  
  139. const originalFocusFn = HTMLElement.prototype.focus;
  140.  
  141. let maxTrial = 16;
  142. while (!document || !document.documentElement) {
  143. await new Promise(requestAnimationFrame);
  144. if (--maxTrial < 0) return;
  145. }
  146.  
  147. const SCRIPT_TAG = "Selection and Copying Restorer (Universal)";
  148. const $nil = () => { };
  149.  
  150. let focusNotAllowedUntil = 0;
  151.  
  152. function isLatestBrowser() {
  153. let res;
  154. try {
  155. let o = { $nil };
  156. o?.$nil();
  157. o = null;
  158. o?.$nil();
  159. res = true;
  160. } catch (e) { }
  161. return !!res;
  162. }
  163. if (!isLatestBrowser()) console.warn(`${SCRIPT_TAG}: Browser version before 2020-01-01 is not recommended. Please update to the latest version.`);
  164.  
  165. function getEventListenerSupport() {
  166. if ('_b1850' in $) return $._b1850
  167. let prop = 0;
  168. document.createAttribute('z').addEventListener('nil', $nil, {
  169. get passive() {
  170. prop |= 1;
  171. },
  172. get once() {
  173. prop |= 2;
  174. }
  175. });
  176. return ($._b1850 = prop);
  177. }
  178.  
  179. function isSupportAdvancedEventListener() {
  180. return (getEventListenerSupport() & 3) === 3;
  181. }
  182.  
  183. function isSupportPassiveEventListener() {
  184. return (getEventListenerSupport() & 1) === 1;
  185. }
  186.  
  187. function inIframe() {
  188. try {
  189. return window.self !== window.top;
  190. } catch (e) {
  191. return true;
  192. }
  193. }
  194.  
  195.  
  196. /* globals WeakRef:false */
  197.  
  198. /** @type {(o: Object | null) => WeakRef | null} */
  199. const mWeakRef = typeof WeakRef === 'function' ? (o => o ? new WeakRef(o) : null) : (o => o || null);
  200.  
  201. /** @type {(wr: Object | null) => Object | null} */
  202. const kRef = (wr => (wr && wr.deref) ? wr.deref() : wr);
  203.  
  204. /*
  205. const whiteListForCustomContextMenu = [
  206. 'https://drive.google.com/',
  207. 'https://mail.google.com/',
  208. 'https://www.google.com/maps/',
  209. 'https://www.dropbox.com/',
  210. 'https://outlook.live.com/mail/'
  211. ];
  212. const isCustomContextMenuAllowedFn = () => {
  213. const href = location.href;
  214. for (h of whiteListForCustomContextMenu) {
  215. if (href.startsWith(h)) return true;
  216. }
  217. return false;
  218. }
  219. */
  220. const isCustomContextMenuAllowedFn = () => { return false; }
  221. let isCustomContextMenuAllowed = null;
  222. const $ = {
  223. utSelectionColorHack: 'msmtwejkzrqa',
  224. utTapHighlight: 'xfcklblvkjsj',
  225. utLpSelection: 'gykqyzwufxpz',
  226. utHoverBlock: 'meefgeibrtqx', // scc_emptyblock
  227. // utNonEmptyElm: 'ilkpvtsnwmjb',
  228. utNonEmptyElmPrevElm: 'jttkfplemwzo',
  229. utHoverTextWrap: 'oseksntfvucn',
  230. ksFuncReplacerCounter: '___dqzadwpujtct___',
  231. ksEventReturnValue: ' ___ndjfujndrlsx___',
  232. ksSetData: '___rgqclrdllmhr___',
  233. ksNonEmptyPlainText: '___grpvyosdjhuk___',
  234.  
  235. eh_capture_passive: () => isSupportPassiveEventListener() ? ($._eh_capture_passive = ($._eh_capture_passive || {
  236. capture: true,
  237. passive: true
  238. })) : true,
  239. eh_capture_active: () => isSupportPassiveEventListener() ? ($._eh_capture_passive = ($._eh_capture_passive || {
  240. capture: true,
  241. passive: false
  242. })) : true,
  243.  
  244. mAlert_DOWN: $nil, // dummy function in case alert replacement is not valid
  245. mAlert_UP: $nil, // dummy function in case alert replacement is not valid
  246.  
  247.  
  248. lpKeyPressing: false,
  249. lpKeyPressingPromise: Promise.resolve(),
  250.  
  251. /** @readonly */
  252. weakMapFuncReplaced: new WeakMap(),
  253. ksFuncReplacerCounterId: 0,
  254. isStackCheckForFuncReplacer: false, // multi-line stack in FireFox
  255. isGlobalEventCheckForFuncReplacer: false,
  256. enableReturnValueReplacment: false, // set true by code
  257.  
  258. /** @readonly */
  259. eyEvts: ['keydown', 'keyup', 'copy', 'contextmenu', 'select', 'selectstart', 'dragstart', 'beforecopy'], // slope: throughout
  260. delayMouseUpTasks: 0,
  261.  
  262. isNum: (d) => (d > 0 || d < 0 || d === 0),
  263.  
  264. getNodeType: (n) => ((n instanceof Node) ? n.nodeType : -1),
  265.  
  266. isAnySelection: function () {
  267. const sel = getSelection();
  268. return !sel ? null : (typeof sel.isCollapsed === 'boolean') ? !sel.isCollapsed : (sel.toString().length > 0);
  269. },
  270.  
  271. updateIsWindowEventSupported: function () {
  272. // https://developer.mozilla.org/en-US/docs/Web/API/Window/event
  273. // FireFox >= 66
  274. let p = document.createElement('noscript');
  275. p.onclick = function (ev) { $.isGlobalEventCheckForFuncReplacer = (window.event === ev) };
  276. p.dispatchEvent(new Event('click'));
  277. p = null;
  278. },
  279.  
  280. /**
  281. *
  282. * @param {string} cssStyle
  283. * @param {Node?} container
  284. * @returns
  285. */
  286. createCSSElement: function (cssStyle, container) {
  287. const css = document.createElement('style'); // slope: DOM throughout
  288. css.textContent = cssStyle;
  289. if (container) container.appendChild(css);
  290. return css;
  291. },
  292.  
  293. createFakeAlert: function (_alert) {
  294. if (typeof _alert !== 'function') return null;
  295.  
  296. function alert(msg) {
  297. alert.__isDisabled__() ? console.log("alert msg disabled: ", msg) : _alert.apply(this, arguments);
  298. };
  299. alert.toString = _alert.toString.bind(_alert);
  300. return alert;
  301. },
  302.  
  303. /**
  304. *
  305. * @param {Function} originalFunc
  306. * @param {string} pName
  307. * @returns
  308. */
  309. createFuncReplacer: function (originalFunc) {
  310. const id = ++$.ksFuncReplacerCounterId;
  311. const resFX = function (ev) {
  312. const res = originalFunc.apply(this, arguments);
  313. if (res === false) {
  314. if (!this || !ev) return false;
  315. const pName = 'on' + ev.type;
  316. const selfFunc = this[pName];
  317. if (typeof selfFunc !== 'function') return false;
  318. if (selfFunc[$.ksFuncReplacerCounter] !== id) return false;
  319. // if this is null or undefined, or this.onXXX is not this function
  320. if (ev.cancelable !== false && $.isDeactivePreventDefault(ev)) {
  321. if ($.isGlobalEventCheckForFuncReplacer === true) {
  322. if (window.event !== ev) return false; // eslint-disable-line
  323. }
  324. if ($.isStackCheckForFuncReplacer === true) {
  325. let stack = (new Error()).stack;
  326. let onlyOneLineStack = stack.indexOf('\n') === stack.lastIndexOf('\n');
  327. if (onlyOneLineStack === false) return false;
  328. }
  329. return true;
  330. }
  331. }
  332. return res;
  333. }
  334. resFX[$.ksFuncReplacerCounter] = id;
  335. resFX.toString = originalFunc.toString.bind(originalFunc);
  336. $.weakMapFuncReplaced.set(originalFunc, resFX);
  337. return resFX;
  338. },
  339.  
  340.  
  341. // listenerDisableAll: async (evt) => {
  342. // },
  343.  
  344. onceCssHighlightSelection: async () => {
  345. if (document.documentElement.hasAttribute($.utLpSelection)) return;
  346. $.onceCssHighlightSelection = null
  347. await Promise.resolve();
  348. 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
  349. const elm = !s.length ? document.body : s[s.length >> 1];
  350. await Promise.resolve();
  351. const selectionStyle = getComputedStyle(elm, '::selection');
  352. let selectionBackgroundColor = selectionStyle.getPropertyValue('background-color') || '';
  353. if (selectionBackgroundColor.length > 9 && /^rgba\(\d+,\s*\d+,\s*\d+,\s*0\)$/.test(selectionBackgroundColor)) {
  354. document.documentElement.setAttribute($.utSelectionColorHack, "");
  355. } else {
  356. let bodyBackgroundColor = getComputedStyle(document.body).getPropertyValue('background-color') || '';
  357. if (bodyBackgroundColor === selectionBackgroundColor) {
  358. document.documentElement.setAttribute($.utSelectionColorHack, "");
  359. }
  360. }
  361. await Promise.resolve();
  362. const elmStyle = getComputedStyle(elm);
  363. let highlightColor = elmStyle.getPropertyValue('-webkit-tap-highlight-color') || '';
  364. if (highlightColor.length > 9 && /^rgba\(\d+,\s*\d+,\s*\d+,\s*0\)$/.test(highlightColor)) document.documentElement.setAttribute($.utTapHighlight, "");
  365. document.documentElement.setAttribute($.utTapHighlight, "");
  366. },
  367.  
  368. clipDataProcess: function (clipboardData) {
  369.  
  370. if (!clipboardData) return;
  371. const evt = kRef(clipboardData[$.ksSetData]); // NOT NULL when preventDefault is called
  372. if (!evt || evt.clipboardData !== clipboardData) return;
  373. const plainText = clipboardData[$.ksNonEmptyPlainText]; // NOT NULL when setData is called with non empty input
  374. if (!plainText) return;
  375.  
  376. // BOTH preventDefault and setData are called.
  377.  
  378. if (evt.cancelable === false || evt.defaultPrevented === true) return;
  379.  
  380.  
  381. // ---- disable text replacement on plain text node(s) ----
  382.  
  383. let cSelection = getSelection();
  384. if (!cSelection) return; // ?
  385. let exactSelectionText = cSelection.toString();
  386. let trimedSelectionText = exactSelectionText.trim();
  387. if (exactSelectionText.length > 0 && exactSelectionText.length < plainText.length) {
  388. let pSelection = trimedSelectionText.replace(/[\r\n\t\b\x20\xA0\u200b\uFEFF\u3000]+/g, '');
  389. let pRequest = plainText.replace(/[\r\n\t\b\x20\xA0\u200b\uFEFF\u3000]+/g, '');
  390. // a newline char (\n) could be generated between nodes.
  391. let search = pRequest.indexOf(pSelection);
  392. if (search >= 0 && search < (plainText.length / 2) + 1 && $.getNodeType(cSelection.anchorNode) === 3 && $.getNodeType(cSelection.focusNode) === 3) {
  393. console.log({
  394. msg: "copy event - clipboardData replacement is NOT allowed as the text node(s) is/are selected.",
  395. oldText: trimedSelectionText,
  396. newText: plainText,
  397. })
  398. return;
  399. }
  400. }
  401.  
  402. // --- allow preventDefault for text replacement ---
  403.  
  404. $.bypass = true;
  405. evt.preventDefault();
  406. $.bypass = false;
  407.  
  408. // ---- message log ----
  409.  
  410.  
  411. if (trimedSelectionText) {
  412. // there is replacement data and the selection is not empty
  413. console.log({
  414. msg: "copy event - clipboardData replacement is allowed and the selection is not empty",
  415. oldText: trimedSelectionText,
  416. newText: plainText,
  417. })
  418. } else {
  419. // there is replacement data and the selection is empty
  420. console.log({
  421. msg: "copy event - clipboardData replacement is allowed and the selection is empty",
  422. oldText: trimedSelectionText,
  423. newText: plainText,
  424. })
  425. }
  426.  
  427. },
  428.  
  429. isDeactivePreventDefault: function (evt) {
  430. if (!evt || $.bypass) return false;
  431. let j = $.eyEvts.indexOf(evt.type);
  432. const target = evt.target;
  433. switch (j) {
  434. case 6: // dragstart
  435.  
  436. if (isCustomContextMenuAllowed === null) isCustomContextMenuAllowed = isCustomContextMenuAllowedFn();
  437. if (isCustomContextMenuAllowed) return false;
  438.  
  439. if ($.enableDragging) return false;
  440. if (target instanceof Element && target.hasAttribute('draggable')) {
  441. $.enableDragging = true;
  442. return false;
  443. }
  444. // if(evt.target.hasAttribute('draggable')&&evt.target!=window.getSelection().anchorNode)return false;
  445. return true;
  446. case 3: // contextmenu
  447.  
  448. if (isCustomContextMenuAllowed === null) isCustomContextMenuAllowed = isCustomContextMenuAllowedFn();
  449. if (isCustomContextMenuAllowed) return false;
  450.  
  451. if (target instanceof Element) {
  452. switch (target.nodeName) {
  453. case 'IMG':
  454. case 'SPAN':
  455. case 'P':
  456. case 'BODY':
  457. case 'HTML':
  458. case 'A':
  459. case 'B':
  460. case 'I':
  461. case 'PRE':
  462. case 'CODE':
  463. case 'CENTER':
  464. case 'SMALL':
  465. case 'SUB':
  466. case 'SAMP':
  467. return true;
  468. case 'VIDEO':
  469. case 'AUDIO':
  470. return $.gm_native_video_audio_contextmenu ? true : false;
  471.  
  472. }
  473. if (target.closest('ytd-player#ytd-player')) return false;
  474. if ((target.textContent || "").trim().length === 0 && target.querySelector('video, audio')) {
  475. return false; // exclude elements like video
  476. }
  477. }
  478. return true;
  479. case -1:
  480. return false;
  481. case 0: // keydown
  482. case 1: // keyup
  483.  
  484. if (isCustomContextMenuAllowed === null) isCustomContextMenuAllowed = isCustomContextMenuAllowedFn();
  485. if (isCustomContextMenuAllowed) return false;
  486. return (evt.keyCode === 67 && (evt.ctrlKey || evt.metaKey) && !evt.altKey && !evt.shiftKey && $.isAnySelection() === true);
  487. case 2: // copy
  488.  
  489. if (isCustomContextMenuAllowed === null) isCustomContextMenuAllowed = isCustomContextMenuAllowedFn();
  490. if (isCustomContextMenuAllowed) return false;
  491.  
  492. if (!('clipboardData' in evt && 'setData' in DataTransfer.prototype)) return true; // Event oncopy not supporting clipboardData
  493. if (evt.cancelable === false || evt.defaultPrevented === true) return true;
  494.  
  495. const cd = kRef(evt.clipboardData[$.ksSetData]);
  496. if (cd && cd !== evt) return true; // in case there is a bug
  497. evt.clipboardData[$.ksSetData] = mWeakRef(evt);
  498.  
  499. $.clipDataProcess(evt.clipboardData);
  500.  
  501. return true; // preventDefault in clipDataProcess
  502.  
  503.  
  504. default:
  505. return true;
  506. }
  507. },
  508.  
  509. enableSelectClickCopy: function () {
  510.  
  511. !(function ($setData) {
  512. DataTransfer.prototype.setData = (function setData() {
  513.  
  514. if (arguments[0] === 'text/plain' && typeof arguments[1] === 'string') {
  515. if (arguments[1].trim().length > 0) {
  516. this[$.ksNonEmptyPlainText] = arguments[1]
  517. } else if (this[$.ksNonEmptyPlainText]) {
  518. arguments[1] = this[$.ksNonEmptyPlainText]
  519. }
  520. }
  521.  
  522. $.clipDataProcess(this)
  523.  
  524. let res = $setData.apply(this, arguments)
  525.  
  526. return res;
  527.  
  528. })
  529. })(DataTransfer.prototype.setData);
  530.  
  531. Object.defineProperties(DataTransfer.prototype, {
  532. [$.ksSetData]: { // store the event
  533. value: null,
  534. writable: true,
  535. enumerable: false,
  536. configurable: true
  537. },
  538. [$.ksNonEmptyPlainText]: { // store the text
  539. value: null,
  540. writable: true,
  541. enumerable: false,
  542. configurable: true
  543. }
  544. })
  545.  
  546.  
  547. Event.prototype.preventDefault = (function (f) {
  548. function preventDefault() {
  549. if (this.cancelable !== false && !$.isDeactivePreventDefault(this)) f.call(this);
  550. }
  551. preventDefault.toString = f.toString.bind(f);
  552. return preventDefault;
  553. })(Event.prototype.preventDefault);
  554.  
  555. (() => {
  556. const pd = Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(Event.prototype, 'returnValue') : {};
  557. const { get, set } = pd;
  558. if (get && set) {
  559. const filterTypes = new Set($.eyEvts);
  560. Object.defineProperty(Event.prototype, "returnValue", {
  561. get() {
  562. const type = this.type;
  563. if (!filterTypes.has(type)) return get.call(this);
  564. return $.ksEventReturnValue in this ? this[$.ksEventReturnValue] : true;
  565. },
  566. set(newValue) {
  567. const type = this.type;
  568. if (!filterTypes.has(type)) return set.call(this, newValue);
  569. const convertedNV = !!newValue;
  570. if (convertedNV === false) this.preventDefault();
  571. if (this[$.ksEventReturnValue] !== false) {
  572. this[$.ksEventReturnValue] = convertedNV;
  573. }
  574. },
  575. enumerable: true,
  576. configurable: true
  577. });
  578. } else {
  579. Object.defineProperty(Event.prototype, "returnValue", {
  580. get() {
  581. return $.ksEventReturnValue in this ? this[$.ksEventReturnValue] : true;
  582. },
  583. set(newValue) {
  584. if (newValue === false) this.preventDefault();
  585. this[$.ksEventReturnValue] = newValue;
  586. },
  587. enumerable: true,
  588. configurable: true
  589. });
  590. }
  591. })();
  592.  
  593. $.enableReturnValueReplacment = true;
  594. // for (const eyEvt of $.eyEvts) {
  595. // document.addEventListener(eyEvt, $.listenerDisableAll, true); // Capture Event; passive:false; expected occurrence COMPLETELY before Target Capture and Target Bubble
  596. // }
  597.  
  598. // userscript bug ? window.alert not working
  599. /** @type {Window | null} */
  600. let window_ = uWin;
  601. if (window_) {
  602. let _alert = window_.alert; // slope: temporary
  603. if (typeof _alert === 'function') {
  604. let _mAlert = $.createFakeAlert(_alert);
  605. if (_mAlert) {
  606. let clickBlockingTo = 0;
  607. _mAlert.__isDisabled__ = () => clickBlockingTo > +new Date;
  608. $.mAlert_DOWN = () => (clickBlockingTo = +new Date + 50);
  609. $.mAlert_UP = () => (clickBlockingTo = +new Date + 20);
  610. window_.alert = _mAlert
  611. }
  612. _mAlert = null;
  613. }
  614. _alert = null;
  615. }
  616. window_ = null;
  617.  
  618. },
  619.  
  620. lpCheckPointer: function (targetElm) {
  621. if (targetElm instanceof Element && targetElm.matches('*:hover')) {
  622. if (getComputedStyle(targetElm).getPropertyValue('cursor') === 'pointer' && targetElm.textContent) return true;
  623. }
  624. return false;
  625. },
  626.  
  627. /**
  628. *
  629. * @param {Event} evt
  630. * @param {boolean} toPreventDefault
  631. */
  632. eventCancel: function (evt, toPreventDefault) {
  633. $.bypass = true;
  634. !toPreventDefault || evt.preventDefault()
  635. evt.stopPropagation();
  636. evt.stopImmediatePropagation();
  637. $.bypass = false;
  638. },
  639.  
  640. lpHoverBlocks: [],
  641. lpKeyAltLastPressAt: 0,
  642. lpKeyAltPressInterval: 0,
  643.  
  644. noPlayingVideo: function () {
  645.  
  646. // prevent poor video preformance
  647.  
  648. let noPlaying = true;
  649. for (const video of document.querySelectorAll('video[src]')) {
  650.  
  651. if (video.paused === false) {
  652. noPlaying = false;
  653. break;
  654. }
  655.  
  656. }
  657. return noPlaying;
  658.  
  659.  
  660. },
  661.  
  662.  
  663.  
  664. /** @type {EventListener} */
  665. lpKeyDown: (evt) => {
  666.  
  667. if (!$.gm_lp_enable) return;
  668.  
  669. const isAltPress = (evt.key === "Alt" && evt.altKey && !evt.ctrlKey && !evt.metaKey && !evt.shiftKey);
  670.  
  671. if (isAltPress) {
  672.  
  673. $.lpKeyAltLastPressAt = +new Date;
  674.  
  675. let element = evt.target;
  676.  
  677.  
  678. if ($.lpKeyPressing === false && (element instanceof Node) && element.parentNode && !evt.repeat && $.noPlayingVideo()) {
  679.  
  680. $.lpKeyPressing = true;
  681.  
  682. $.cid_lpKeyPressing = setInterval(() => {
  683. if ($.lpKeyAltLastPressAt + 500 < +new Date) {
  684. $.lpCancelKeyPressAlt();
  685. }
  686. }, 137);
  687.  
  688. const rootNode = $.rootHTML(element);
  689. if (rootNode) {
  690. let tmp_wmEty = null;
  691.  
  692.  
  693. let wmTextWrap = new WeakMap();
  694.  
  695. $.lpKeyPressingPromise = $.lpKeyPressingPromise.then(() => {
  696. for (const elm of $.lpHoverBlocks) {
  697. elm.removeAttribute($.utNonEmptyElmPrevElm)
  698. elm.removeAttribute($.utHoverTextWrap)
  699. }
  700. $.lpHoverBlocks.length = 0;
  701. }).then(() => {
  702. tmp_wmEty = new WeakMap(); // 1,2,3.....: non-empty elm, -1:empty elm
  703. const s = [...rootNode.querySelectorAll('*:not(button, textarea, input, script, noscript, style, link, img, br)')].filter((elm) => elm.childElementCount === 0 && (elm.textContent || '').trim().length > 0)
  704. for (const elm of s) tmp_wmEty.set(elm, 1);
  705. return s;
  706. }).then((s) => {
  707. let laterArr = [];
  708. let promises = [];
  709.  
  710. let promiseCallback = parentNode => {
  711. if (wmTextWrap.get(parentNode) !== null) return;
  712. const m = [...parentNode.children].some(elm => {
  713. const value = getComputedStyle(elm).getPropertyValue('z-index') || '';
  714. if (value.length > 0) return $.isNum(+value)
  715. return false
  716. })
  717. wmTextWrap.set(parentNode, m)
  718. if (m) {
  719. $.lpHoverBlocks.push(parentNode);
  720. parentNode.setAttribute($.utHoverTextWrap, '')
  721. }
  722.  
  723. };
  724.  
  725. for (const elm of s) {
  726. let qElm = elm;
  727. let qi = 1;
  728. while (true) {
  729. let pElm = qElm.previousElementSibling;
  730. let anyEmptyHover = false;
  731. while (pElm) {
  732. if (tmp_wmEty.get(pElm) > 0) break;
  733. if (!pElm.matches(`button, textarea, input, script, noscript, style, link, img, br`) && (pElm.textContent || '').length === 0 && pElm.clientWidth * pElm.clientHeight > 0) {
  734. laterArr.push(pElm);
  735. anyEmptyHover = true;
  736. }
  737. pElm = pElm.previousElementSibling;
  738. }
  739. if (anyEmptyHover && !wmTextWrap.has(qElm.parentNode)) {
  740. wmTextWrap.set(qElm.parentNode, null)
  741. promises.push(Promise.resolve(qElm.parentNode).then(promiseCallback))
  742. }
  743. qElm = qElm.parentNode;
  744. if (!qElm || qElm === rootNode) break;
  745. qi++
  746. if (tmp_wmEty.get(qElm) > 0) break;
  747. tmp_wmEty.set(qElm, qi)
  748. }
  749. }
  750.  
  751. tmp_wmEty = null;
  752.  
  753. Promise.all(promises).then(() => {
  754. promises.length = 0;
  755. promises = null;
  756. promiseCallback = null;
  757. for (const pElm of laterArr) {
  758. let parentNode = pElm.parentNode
  759. if (wmTextWrap.get(parentNode) === true) {
  760. $.lpHoverBlocks.push(pElm);
  761. pElm.setAttribute($.utNonEmptyElmPrevElm, '');
  762. }
  763. }
  764. laterArr.length = 0;
  765. laterArr = null;
  766. wmTextWrap = null;
  767. })
  768. })
  769.  
  770. }
  771.  
  772. }
  773.  
  774.  
  775. } else if ($.lpKeyPressing === true) {
  776.  
  777. $.lpCancelKeyPressAlt();
  778.  
  779. }
  780.  
  781. },
  782. lpCancelKeyPressAlt: () => {
  783. $.lpKeyPressing = false;
  784. if ($.cid_lpKeyPressing > 0) $.cid_lpKeyPressing = clearInterval($.cid_lpKeyPressing);
  785.  
  786. $.lpKeyPressingPromise = $.lpKeyPressingPromise.then(() => {
  787. for (const elm of $.lpHoverBlocks) {
  788. elm.removeAttribute($.utNonEmptyElmPrevElm);
  789. elm.removeAttribute($.utHoverTextWrap);
  790. }
  791. $.lpHoverBlocks.length = 0;
  792. })
  793.  
  794. setTimeout(function () {
  795. if ($.lpMouseActive === 1) {
  796. $.lpMouseUpClear();
  797. $.lpMouseActive = 0;
  798. }
  799. }, 32);
  800.  
  801. },
  802. /** @type {EventListener} */
  803. lpKeyUp: (evt) => {
  804.  
  805. if (!$.gm_lp_enable) return;
  806.  
  807. if ($.lpKeyPressing === true) {
  808. $.lpCancelKeyPressAlt();
  809. }
  810.  
  811. },
  812.  
  813. lpAltRoots: [],
  814.  
  815. /** @type {EventListener} */
  816. lpMouseDown: (evt) => {
  817.  
  818. if (!$.gm_lp_enable) return;
  819.  
  820. $.lpMouseActive = 0;
  821. if (evt.altKey && !evt.ctrlKey && !evt.metaKey && !evt.shiftKey && evt.button === 0 && (evt.target instanceof Node) && $.noPlayingVideo()) {
  822. $.lpMouseActive = 1;
  823. $.eventCancel(evt, false);
  824. const rootNode = $.rootHTML(evt.target);
  825. $.lpAltRoots.push(rootNode);
  826. rootNode.setAttribute($.utLpSelection, '');
  827. }
  828. },
  829.  
  830. lpMouseUpClear: function () {
  831. for (const rootNode of $.lpAltRoots) rootNode.removeAttribute($.utLpSelection);
  832. $.lpAltRoots.length = 0;
  833. if ($.onceCssHighlightSelection) requestAnimationFrame($.onceCssHighlightSelection);
  834. },
  835.  
  836. /** @type {EventListener} */
  837. lpMouseUp: (evt) => {
  838.  
  839. if (!$.gm_lp_enable) return;
  840.  
  841. if ($.lpMouseActive === 1) {
  842. $.lpMouseActive = 2;
  843. $.eventCancel(evt, false);
  844. $.lpMouseUpClear();
  845. }
  846. },
  847.  
  848. /** @type {EventListener} */
  849. lpClick: (evt) => {
  850.  
  851. if (!$.gm_lp_enable) return;
  852.  
  853. if ($.lpMouseActive === 2) {
  854. $.eventCancel(evt, false);
  855. }
  856. },
  857.  
  858. lpEnable: function () { // this is an optional feature for modern browser
  859. // the built-in browser feature has already disabled the default event behavior, the coding is just to ensure no "tailor-made behavior" occuring.
  860. const opt = $.eh_capture_passive();
  861. document.addEventListener('keydown', $.lpKeyDown, opt)
  862. document.addEventListener('keyup', $.lpKeyUp, opt)
  863. document.addEventListener('mousedown', $.lpMouseDown, opt)
  864. document.addEventListener('mouseup', $.lpMouseUp, opt)
  865. document.addEventListener('click', $.lpClick, opt)
  866. },
  867.  
  868. /**
  869. *
  870. * @param {Node | null} node
  871. * @returns
  872. */
  873. rootHTML: (node) => {
  874.  
  875. if (!(node instanceof Node)) return null;
  876. if (!node.ownerDocument) return node;
  877. let rootNode = node.getRootNode ? node.getRootNode() : null
  878. if (!rootNode) {
  879. let pElm = node;
  880. for (let parentNode; parentNode = pElm.parentNode;) {
  881. pElm = parentNode;
  882. }
  883. rootNode = pElm;
  884. }
  885.  
  886.  
  887. rootNode = rootNode.querySelector('html') || node.ownerDocument.documentElement || null;
  888. return rootNode
  889.  
  890. },
  891.  
  892. // note: "user-select: XXX" is deemed as invalid property value in FireFox.
  893.  
  894. injectCSSRules: () => {
  895. const cssStyleOnReady = `
  896.  
  897. html {
  898. --sac-user-select: auto;
  899. }
  900. [role="slider"], input, textarea, video[src], :empty {
  901. --sac-user-select: nil;
  902. }
  903. label:not(:empty) {
  904. --sac-user-select: auto;
  905. }
  906.  
  907. html, html *,
  908. html *[style], html *[class] {
  909. -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;
  910. }
  911.  
  912. html *:hover, html *:link, html *:visited, html *:active {
  913. -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;
  914. }
  915.  
  916. html *::before, html *::after {
  917. -webkit-touch-callout: default !important; -moz-user-select: auto !important; -webkit-user-select: auto !important; user-select: auto !important;
  918. }
  919.  
  920. *:hover>img[src]{pointer-events:auto !important;}
  921.  
  922. [${$.utSelectionColorHack}] :not(input):not(textarea)::selection{ background-color: Highlight !important; color: HighlightText !important;}
  923. [${$.utSelectionColorHack}] :not(input):not(textarea)::-moz-selection{ background-color: Highlight !important; color: HighlightText !important;}
  924. [${$.utTapHighlight}] *{ -webkit-tap-highlight-color: rgba(0, 0, 0, 0.18) !important;}
  925.  
  926. [${$.utHoverTextWrap}]>[${$.utNonEmptyElmPrevElm}]{pointer-events:none !important;}
  927. [${$.utHoverTextWrap}]>*{z-index:inherit !important;}
  928.  
  929. html[${$.utLpSelection}] *:hover, html[${$.utLpSelection}] *:hover * { cursor:text !important;}
  930. html[${$.utLpSelection}] :not(input):not(textarea)::selection {background-color: rgba(255, 156, 179, 0.5) !important;}
  931. html[${$.utLpSelection}] :not(input):not(textarea)::-moz-selection {background-color: rgba(255, 156, 179, 0.5) !important;}
  932.  
  933. img[${$.utHoverBlock}="4"]{display:none !important;}
  934. [${$.utHoverBlock}="7"]{padding:0 !important;overflow:hidden !important;}
  935. [${$.utHoverBlock}="7"]>img[${$.utHoverBlock}="4"]:first-child{
  936. display:inline-block !important;
  937. position: relative !important;
  938. top: auto !important;
  939. left: auto !important;
  940. bottom: auto !important;
  941. right: auto !important;
  942. opacity: 0 !important;
  943. padding: 0 !important;
  944. margin: 0 !important;
  945. width: 100% !important;
  946. height: 100% !important;
  947. outline: 0 !important;
  948. border: 0 !important;
  949. box-sizing: border-box !important;
  950. transform: initial !important;
  951. -moz-user-select: none !important;
  952. -webkit-user-select: none !important;
  953. user-select: none !important;
  954. z-index:1 !important;
  955. float: left !important;
  956. cursor:inherit !important;
  957. pointer-events:inherit !important;
  958. border-radius: inherit !important;
  959. background:none !important;
  960. }
  961.  
  962. `.trim();
  963. $.createCSSElement(cssStyleOnReady, document.documentElement);
  964. },
  965.  
  966. disableHoverBlock: () => {
  967.  
  968. const nMap = new WeakMap();
  969.  
  970. /**
  971. *
  972. * @param {HTMLElement} elm
  973. * @returns
  974. */
  975. function elmParam(elm) {
  976. let mElm = nMap.get(elm);
  977. if (!mElm) nMap.set(elm, mElm = {});
  978. return mElm;
  979. }
  980.  
  981. /**
  982. *
  983. * @param {DOMRect} rect1
  984. * @param {DOMRect} rect2
  985. * @returns
  986. */
  987. function overlapArea(rect1, rect2) {
  988.  
  989. let l1 = {
  990. x: rect1.left,
  991. y: rect1.top
  992. }
  993.  
  994. let r1 = {
  995. x: rect1.right,
  996. y: rect1.bottom
  997. }
  998. let l2 = {
  999. x: rect2.left,
  1000. y: rect2.top
  1001. }
  1002.  
  1003. let r2 = {
  1004. x: rect2.right,
  1005. y: rect2.bottom
  1006. }
  1007.  
  1008. // Area of 1st Rectangle
  1009. let area1 = Math.abs(l1.x - r1.x) * Math.abs(l1.y - r1.y);
  1010.  
  1011. // Area of 2nd Rectangle
  1012. let area2 = Math.abs(l2.x - r2.x) * Math.abs(l2.y - r2.y);
  1013.  
  1014. // Length of intersecting part i.e
  1015. // start from max(l1.x, l2.x) of
  1016. // x-coordinate and end at min(r1.x,
  1017. // r2.x) x-coordinate by subtracting
  1018. // start from end we get required
  1019. // lengths
  1020. let x_dist = Math.min(r1.x, r2.x) - Math.max(l1.x, l2.x);
  1021. let y_dist = Math.min(r1.y, r2.y) - Math.max(l1.y, l2.y);
  1022. let areaI = 0;
  1023. if (x_dist > 0 && y_dist > 0) {
  1024. areaI = x_dist * y_dist;
  1025. }
  1026.  
  1027. return {
  1028. area1,
  1029. area2,
  1030. areaI
  1031. };
  1032.  
  1033.  
  1034. }
  1035.  
  1036. function redirectEvent(event, toElement) {
  1037.  
  1038. toElement.dispatchEvent(new event.constructor(event.type, event));
  1039. if (event.type !== 'wheel') event.preventDefault();
  1040. event.stopPropagation();
  1041. }
  1042.  
  1043. /** @type {WeakMap<Node, number>} */
  1044. const floatingBlockHover = new WeakMap();
  1045.  
  1046. /**
  1047. @typedef NImg
  1048. @type {Object}
  1049. @property {HTMLImageElement} elm The Image Element
  1050. @property {number} lastTime lastTime
  1051. @property {number} cid_fade cid for fade
  1052.  
  1053. */
  1054.  
  1055. /** @type { NImg[] } */
  1056. let _nImgs = [];
  1057. const handleNImgs = async (img) => {
  1058. await Promise.resolve();
  1059. for (const s of _nImgs) {
  1060. if (s.elm === img) {
  1061. s.lastTime = +new Date
  1062. }
  1063. }
  1064. }
  1065.  
  1066. function nImgFunc() {
  1067.  
  1068. for (const s of _nImgs) {
  1069. if (s.lastTime + 800 < +new Date) {
  1070. s.lastTime = +new Date;
  1071. return s.elm
  1072. }
  1073. }
  1074.  
  1075. let nImg = document.createElement('img');
  1076. nImg.setAttribute('title', ' ');
  1077. nImg.setAttribute('alt', ' ');
  1078. nImg.onerror = function () {
  1079. if (this.parentNode instanceof Node) this.parentNode.removeChild(this)
  1080. }
  1081. nImg.setAttribute($.utHoverBlock, '4');
  1082. const handle = function (event) {
  1083. if (this === event.target) {
  1084. if (event.button !== 2) redirectEvent(event, this.parentNode)
  1085. handleNImgs(this);
  1086. }
  1087. }
  1088. nImg.addEventListener('click', handle, true);
  1089. nImg.addEventListener('mousedown', handle, true);
  1090. nImg.addEventListener('mouseup', handle, true);
  1091. nImg.addEventListener('mousemove', handle, true);
  1092. nImg.addEventListener('mouseover', handle, true);
  1093. nImg.addEventListener('mouseout', handle, true);
  1094. nImg.addEventListener('mouseenter', handle, true);
  1095. nImg.addEventListener('mouseleave', handle, true);
  1096. // nImg.addEventListener('wheel', handle, $.eh_capture_passive());
  1097. let resObj = {
  1098. elm: nImg,
  1099. lastTime: +new Date,
  1100. cid_fade: 0
  1101. }
  1102. _nImgs.push(resObj)
  1103.  
  1104. return nImg;
  1105.  
  1106. }
  1107.  
  1108. const wmHoverUrl = new WeakMap();
  1109. /** @type {Node | null} */
  1110. let lastMouseEnterElm = null;
  1111. let lastMouseEnterAt = 0;
  1112. let lastMouseEnterCid = 0;
  1113.  
  1114. const mouseEnter = async (evt) => {
  1115.  
  1116. if (!$.gm_disablehover_enable) return;
  1117. lastMouseEnterElm = evt.target
  1118. lastMouseEnterAt = +new Date;
  1119.  
  1120. if (lastMouseEnterCid) return;
  1121. lastMouseEnterCid = 1;
  1122. do {
  1123. await new Promise(resolve => setTimeout(resolve, 82));
  1124. } while (+new Date - lastMouseEnterAt < 30);
  1125. lastMouseEnterCid = 0;
  1126.  
  1127. // if($.lpKeyPressing)return;
  1128.  
  1129. /** @type {Node | null} */
  1130. const targetElm = lastMouseEnterElm
  1131.  
  1132. await Promise.resolve();
  1133.  
  1134. if (!targetElm || !targetElm.parentNode) {
  1135. return;
  1136. }
  1137. if (floatingBlockHover.get(targetElm)) {
  1138. let url = null
  1139. if (targetElm.getAttribute($.utHoverBlock) === '7' && (url = wmHoverUrl.get(targetElm)) && targetElm.querySelector(`[${$.utHoverBlock}]`) === null) {
  1140. let _nImg = nImgFunc();
  1141. if (_nImg.parentNode !== targetElm) {
  1142. _nImg.setAttribute('src', url);
  1143. targetElm.insertBefore(_nImg, targetElm.firstChild);
  1144. }
  1145. }
  1146. return;
  1147. }
  1148. floatingBlockHover.set(targetElm, 1);
  1149.  
  1150. await Promise.resolve();
  1151.  
  1152. if (!(targetElm instanceof Element)) return;
  1153. // if (targetElm.nodeType !== 1) return;
  1154. if ("|SVG|IMG|HTML|BODY|VIDEO|AUDIO|BR|HEAD|NOSCRIPT|SCRIPT|STYLE|TEXTAREA|AREA|INPUT|FORM|BUTTON|".indexOf(`|${targetElm.nodeName}|`) >= 0) return;
  1155.  
  1156. const targetArea = targetElm.clientWidth * targetElm.clientHeight
  1157.  
  1158. if (targetArea > 0) { } else {
  1159. return;
  1160. }
  1161.  
  1162. /** @type {string | null} */
  1163. let sUrl = null;
  1164.  
  1165. const targetCSS = getComputedStyle(targetElm)
  1166. const targetBgImage = targetCSS.getPropertyValue('background-image') || '';
  1167. let exec1 = null
  1168.  
  1169. if (targetBgImage.length > 8 && (exec1 = /^\s*url\s*\("?([^"\)]+\b(\.gif|\.png|\.jpeg|\.jpg|\.webp)\b[^"\)]*)"?\)\s*$/i.exec(targetBgImage))) {
  1170. if ((targetElm.textContent || "").trim().length > 0) return;
  1171. const url = exec1[1];
  1172. sUrl = url;
  1173.  
  1174. // console.log(targetBgImage,[...exec1])
  1175. } else {
  1176.  
  1177.  
  1178. if (targetCSS.getPropertyValue('position') === 'absolute' && +targetCSS.getPropertyValue('z-index') > 0) { } else {
  1179. return;
  1180. }
  1181. if ((targetElm.textContent || "").trim().length > 0) return;
  1182.  
  1183. let possibleResults = [];
  1184.  
  1185. for (const imgElm of document.querySelectorAll('img[src]')) {
  1186. const param = elmParam(imgElm)
  1187. if (!param.area) {
  1188. const area = imgElm.clientWidth * imgElm.clientHeight
  1189. if (area > 0) param.area = area;
  1190. }
  1191. if (param.area > 0) {
  1192. if (targetArea > param.area * 0.9) possibleResults.push(imgElm)
  1193. }
  1194. }
  1195.  
  1196. let i = 0;
  1197. let j = 0;
  1198. for (const imgElm of possibleResults) {
  1199.  
  1200. const cmpVal = targetElm.compareDocumentPosition(imgElm)
  1201.  
  1202. /*
  1203.  
  1204. 1: The two nodes do not belong to the same document.
  1205. 2: p1 is positioned after p2.
  1206. 4: p1 is positioned before p2.
  1207. 8: p1 is positioned inside p2.
  1208. 16: p2 is positioned inside p1.
  1209. 32: The two nodes has no relationship, or they are two attributes on the same element.
  1210.  
  1211. */
  1212.  
  1213. if (cmpVal & 8 || cmpVal & 16) return;
  1214. if (cmpVal & 2) j++; // I<p
  1215. else if (cmpVal & 4) break; // I>p
  1216.  
  1217.  
  1218. i++;
  1219.  
  1220. }
  1221.  
  1222. // before: j-1 after: j
  1223.  
  1224. let indexBefore = j - 1;
  1225. let indexAfter = j;
  1226. if (indexBefore < 0) indexBefore = 0;
  1227. if (indexAfter > possibleResults.length - 1) indexAfter = possibleResults.length - 1;
  1228.  
  1229. // setTimeout(function(){
  1230. for (let i = indexBefore; i <= indexAfter; i++) {
  1231. const s = possibleResults[i];
  1232. const {
  1233. area1,
  1234. area2,
  1235. areaI
  1236. } = overlapArea(targetElm.getBoundingClientRect(), s.getBoundingClientRect())
  1237. // const criteria = area1 * 0.7
  1238. if (areaI > 0.9 * area2) {
  1239.  
  1240. sUrl = s.getAttribute('src');
  1241. break;
  1242.  
  1243. }
  1244. }
  1245. // },1000);
  1246.  
  1247. }
  1248.  
  1249.  
  1250.  
  1251.  
  1252. if (typeof sUrl !== 'string') return;
  1253.  
  1254. // console.log(targetElm, targetElm.querySelectorAll('img').length)
  1255.  
  1256. // console.log(313, evt.target, s)
  1257. let _nImg = nImgFunc();
  1258.  
  1259.  
  1260. if (_nImg.parentNode !== targetElm) {
  1261. _nImg.setAttribute('src', sUrl);
  1262. targetElm.insertBefore(_nImg, targetElm.firstChild);
  1263. wmHoverUrl.set(targetElm, sUrl);
  1264. targetElm.setAttribute($.utHoverBlock, '7');
  1265. }
  1266.  
  1267.  
  1268.  
  1269. }
  1270.  
  1271. document.addEventListener('mouseenter', mouseEnter, $.eh_capture_passive())
  1272.  
  1273.  
  1274.  
  1275. },
  1276.  
  1277. /** @type {EventListener} */
  1278. acrAuxDown: (evt) => {
  1279.  
  1280. if (!$.gm_prevent_aux_click_enable) return;
  1281.  
  1282. if (evt.button === 1) {
  1283. let check = $.dmmMouseUpLast > $.dmmMouseDownLast && evt.timeStamp - $.dmmMouseUpLast < 40
  1284. $.dmmMouseDownLast = evt.timeStamp;
  1285. if (check) {
  1286. $.eventCancel(evt, true);
  1287. }
  1288. }
  1289.  
  1290. },
  1291.  
  1292. /** @type {EventListener} */
  1293. acrAuxUp: (evt) => {
  1294. if (!$.gm_prevent_aux_click_enable) return;
  1295.  
  1296. if (evt.button === 1) {
  1297. let check = $.dmmMouseDownLast > $.dmmMouseUpLast && evt.timeStamp - $.dmmMouseDownLast < 40;
  1298. $.dmmMouseUpLast = evt.timeStamp;
  1299. if (check) {
  1300. $.dmmMouseUpCancel = evt.timeStamp;
  1301. $.eventCancel(evt, true);
  1302. }
  1303. }
  1304.  
  1305. },
  1306.  
  1307.  
  1308. /** @type {EventListener} */
  1309. acrAuxClick: (evt) => {
  1310. if (!$.gm_prevent_aux_click_enable) return;
  1311.  
  1312. if (evt.button === 1) {
  1313. if (evt.timeStamp - $.dmmMouseUpCancel < 40) {
  1314. $.eventCancel(evt, true);
  1315. }
  1316. }
  1317.  
  1318.  
  1319. },
  1320.  
  1321. // preventAuxClickRepeat: function () {
  1322.  
  1323. // const opt = $.eh_capture_active();
  1324. // // document.addEventListener('mousedown', $.acrAuxDown, opt)
  1325. // // document.addEventListener('mouseup', $.acrAuxUp, opt)
  1326. // document.addEventListener('auxclick', $.acrAuxClick, opt)
  1327.  
  1328.  
  1329. // },
  1330.  
  1331. mousedownFocus: (evt) => {
  1332. focusNotAllowedUntil = Date.now() + 4;
  1333. },
  1334.  
  1335. mouseupFocus: (evt) => {
  1336. focusNotAllowedUntil = 0;
  1337. },
  1338.  
  1339. MenuEnable: (
  1340. class MenuEnable {
  1341.  
  1342. /**
  1343. *
  1344. * @param {string} textToEnable
  1345. * @param {string} textToDisable
  1346. * @param {Function} callback
  1347. * @param {boolean?} initalEnable
  1348. */
  1349. constructor(textToEnable, textToDisable, callback, initalEnable) {
  1350. /** @type {number|string|null} */
  1351. this.h = null;
  1352. /** @type {string} */
  1353. this.textToEnable = textToEnable;
  1354. /** @type {string} */
  1355. this.textToDisable = textToDisable;
  1356. /** @type {Function} */
  1357. this.callback = callback;
  1358. /** @type {Function} */
  1359. this.gx = this.gx.bind(this);
  1360. }
  1361.  
  1362. unregister() {
  1363. (this.h !== null) ? (GM_unregisterMenuCommand(this.h), (this.h = null)) : null;
  1364. }
  1365.  
  1366. register(text) {
  1367. if (typeof text === 'string') this.showText = text;
  1368. text = this.showText;
  1369. if (typeof text !== 'string') return;
  1370. this.h = GM_registerMenuCommand(text, this.gx);
  1371. }
  1372.  
  1373. a(o) {
  1374.  
  1375. if (this.enabled === o.bEnable) return;
  1376. this.enabled = o.bEnable;
  1377. this.unregister();
  1378.  
  1379.  
  1380. let pr = 0;
  1381.  
  1382. if ($.gm_status_fn_store && $.gm_status_fn_store.indexOf(this) >= 0) {
  1383.  
  1384. let store = $.gm_status_fn_store
  1385. let idx = store.indexOf(this)
  1386. let count = store.length;
  1387.  
  1388.  
  1389. if (idx >= 0 && idx <= count - 2) {
  1390.  
  1391. // console.log(idx, count)
  1392.  
  1393. for (let jdx = idx + 1; jdx < count; jdx++) {
  1394.  
  1395. store[jdx].unregister();
  1396. }
  1397.  
  1398. this.register(o.bText);
  1399.  
  1400. for (let jdx = idx + 1; jdx < count; jdx++) {
  1401.  
  1402. store[jdx].register();
  1403. }
  1404.  
  1405. pr = 1;
  1406.  
  1407. }
  1408.  
  1409.  
  1410. }
  1411.  
  1412. if (!pr) this.register(o.bText);
  1413.  
  1414. this.callback(this.enabled, o.byUserInput);
  1415.  
  1416.  
  1417. }
  1418.  
  1419. enableNow(byUserInput) {
  1420. this.a({
  1421. bEnable: true,
  1422. bText: this.textToDisable,
  1423. byUserInput
  1424. });
  1425.  
  1426. }
  1427.  
  1428. gx() {
  1429. if (this.enabled) this.disableNow(true);
  1430. else this.enableNow(true);
  1431.  
  1432. }
  1433.  
  1434. disableNow(byUserInput) {
  1435. this.a({
  1436. bEnable: false,
  1437. bText: this.textToEnable,
  1438. byUserInput
  1439. });
  1440.  
  1441. }
  1442.  
  1443. toggle(enable, byUserInput) {
  1444. enable ? this.enableNow(byUserInput) : this.disableNow(byUserInput);
  1445. }
  1446.  
  1447. }
  1448. ),
  1449.  
  1450. /**
  1451. *
  1452. * @param {string} gm_name
  1453. * @param {string} textToEnable
  1454. * @param {string} textToDisable
  1455. * @param {Function} callback
  1456. */
  1457. gm_status_fn: async function (gm_name, textToEnable, textToDisable, callback) {
  1458.  
  1459. const menuEnableName = gm_name + "$menuEnable";
  1460.  
  1461. function set_gm(enabled) {
  1462. $[gm_name] = enabled;
  1463. const menuEnable = $[menuEnableName];
  1464. if (menuEnable) {
  1465. menuEnable.toggle(enabled)
  1466. };
  1467. callback(enabled)
  1468. }
  1469.  
  1470. const gmValue = await GM.getValue(gm_name, false);
  1471. set_gm(!!gmValue);
  1472.  
  1473. GM_addValueChangeListener(gm_name, function (name, old_value, new_value, remote) {
  1474.  
  1475. if (old_value === new_value || new_value === $[gm_name]) return;
  1476. set_gm(new_value);
  1477.  
  1478. });
  1479.  
  1480. if (!inIframe()) {
  1481.  
  1482. $.gm_status_fn_store = $.gm_status_fn_store || [];
  1483.  
  1484. $[menuEnableName] = new $.MenuEnable(textToEnable, textToDisable, (enabled) => {
  1485. GM.setValue(gm_name, !!enabled);
  1486. });
  1487.  
  1488. $.gm_status_fn_store.push($[menuEnableName]);
  1489.  
  1490. const gmValue = await GM.getValue(gm_name, false);
  1491. $[menuEnableName].toggle(!!gmValue);
  1492.  
  1493. }
  1494.  
  1495. },
  1496.  
  1497. /** @type {EventListener} */
  1498. genericEventHandlerLevel2: (evt) => {
  1499. if ($.gm_absolute_mode) {
  1500. // inspired by https://greasyfork.org/en/scripts/23772-absolute-enable-right-click-copy
  1501. evt.stopPropagation();
  1502. evt.stopImmediatePropagation();
  1503. }
  1504. // .. and more
  1505.  
  1506. const evtType = (evt || 0).type
  1507.  
  1508. if (evtType && $.enableReturnValueReplacment === true) {
  1509. // $.listenerDisableAll(evt);
  1510. let elmNode = evt.target;
  1511. const pName = 'on' + evtType;
  1512. let maxN = 99;
  1513. while (elmNode instanceof Node) { // i.e. HTMLDocument or HTMLElement
  1514. if (--maxN < 4) break; // prevent unknown case
  1515. const f = elmNode[pName];
  1516. if (typeof f === 'function') {
  1517. let replacerId = f[$.ksFuncReplacerCounter];
  1518. if (replacerId > 0) break; // assume all parent functions are replaced; for performance only
  1519. // note: "return false" is preventDefault() in VanillaJS but preventDefault()+stopPropagation() in jQuery.
  1520. elmNode[pName] = $.weakMapFuncReplaced.get(f) || $.createFuncReplacer(f);
  1521. }
  1522. elmNode = elmNode.parentNode;
  1523. }
  1524. }
  1525.  
  1526. if (evtType === 'contextmenu') {
  1527. if (evt.defaultPrevented !== true) {
  1528. $.mainListenerPress(evt);
  1529. }
  1530. }
  1531.  
  1532. },
  1533.  
  1534. /** @type {EventListener} */
  1535. genericEventHandlerLevel1: (evt) => {
  1536. if ($.gm_absolute_mode) {
  1537. // inspired by https://greasyfork.org/en/scripts/23772-absolute-enable-right-click-copy
  1538. evt.stopPropagation();
  1539. evt.stopImmediatePropagation();
  1540. }
  1541. const evtType = (evt || 0).type
  1542. if (evtType === 'mousedown') {
  1543. $.mousedownFocus(evt);
  1544. $.acrAuxDown(evt);
  1545. if (evt.defaultPrevented !== true) {
  1546. $.mainListenerPress(evt);
  1547. }
  1548. } else if (evtType === 'mouseup') {
  1549. $.mouseupFocus(evt);
  1550. $.acrAuxUp(evt);
  1551. if (evt.defaultPrevented !== true) {
  1552. $.mainListenerRelease(evt);
  1553. }
  1554. }
  1555. },
  1556.  
  1557. eventsInjection: function () {
  1558. for (const s of ['keydown', 'keyup', 'copy', 'contextmenu', 'select', 'selectstart', 'dragstart', 'beforecopy']) {
  1559. document.addEventListener(s, $.genericEventHandlerLevel2, true);
  1560. }
  1561.  
  1562. for (const s of ['cut', 'paste', 'mouseup', 'mousedown', 'drag', 'select']) {
  1563. document.addEventListener(s, $.genericEventHandlerLevel1, true);
  1564. }
  1565.  
  1566. document.addEventListener('auxclick', $.acrAuxClick, true)
  1567. },
  1568.  
  1569. delayMouseUpTasksHandler: () => {
  1570. if ($.delayMouseUpTasks > 0) {
  1571. const flag = $.delayMouseUpTasks
  1572. $.delayMouseUpTasks = 0;
  1573. if ((flag & 1) === 1) $.mAlert_UP();
  1574. if ((flag & 2) === 2 && $.enableDragging === true) $.enableDragging = false;
  1575. }
  1576. },
  1577.  
  1578. mainListenerPress: (evt) => { // Capture Event; (mousedown - desktop; contextmenu - desktop&mobile)
  1579. // $.holdingElm=evt.target;
  1580. // console.log('down',evt.target)
  1581. if ($.onceCssHighlightSelection) requestAnimationFrame($.onceCssHighlightSelection);
  1582. const isContextMenuEvent = evt.type === "contextmenu";
  1583. if (evt.button === 2 || isContextMenuEvent) $.mAlert_DOWN();
  1584. if (isContextMenuEvent && $.delayMouseUpTasks === 0) {
  1585. $.delayMouseUpTasks |= 1;
  1586. requestAnimationFrame($.delayMouseUpTasksHandler)
  1587. }
  1588. },
  1589.  
  1590. mainListenerRelease: (evt) => { // Capture Event; (mouseup - desktop)
  1591. // $.holdingElm=null;
  1592. // console.log('up',evt.target)
  1593. if ($.delayMouseUpTasks === 0) { // skip if it is already queued
  1594. if (evt.button === 2) $.delayMouseUpTasks |= 1;
  1595. if ($.enableDragging === true) $.delayMouseUpTasks |= 2;
  1596. if ($.delayMouseUpTasks > 0) {
  1597. requestAnimationFrame($.delayMouseUpTasksHandler)
  1598. }
  1599. }
  1600. }
  1601.  
  1602.  
  1603. }
  1604.  
  1605. // $.holdingElm=null;
  1606. $.eventsInjection();
  1607. $.enableSelectClickCopy()
  1608. $.injectCSSRules();
  1609.  
  1610. if (isSupportAdvancedEventListener()) $.lpEnable(); // top capture event for alt-click
  1611.  
  1612. $.disableHoverBlock();
  1613. // $.preventAuxClickRepeat();
  1614.  
  1615. console.log(`userscript running - ${SCRIPT_TAG}`);
  1616.  
  1617. $.updateIsWindowEventSupported();
  1618.  
  1619. if (typeof GM_registerMenuCommand === 'function' && typeof GM_unregisterMenuCommand === 'function') {
  1620.  
  1621. if (isSupportAdvancedEventListener()) {
  1622. $.gm_status_fn("gm_lp_enable", "To Enable `Enhanced build-in Alt Text Selection`", "To Disable `Enhanced build-in Alt Text Selection`", () => {
  1623. // callback
  1624. });
  1625. }
  1626. $.gm_status_fn("gm_disablehover_enable", "To Enable `Hover on Image`", "To Disable `Hover on Image`", () => {
  1627. // callback
  1628. });
  1629. $.gm_status_fn("gm_prevent_aux_click_enable", "To Enable `Repetitive AuxClick Prevention`", "To Disable `Repetitive AuxClick Prevention`", () => {
  1630. // callback
  1631. });
  1632. $.gm_status_fn("gm_absolute_mode", "To Enable `Absolute Mode`", "To Disable `Absolute Mode`", () => {
  1633. // callback
  1634. });
  1635.  
  1636. $.gm_status_fn("gm_remain_focus_on_mousedown", "To Enable `Remain Focus On MouseDown`", "To Disable `Remain Focus On MouseDown`", () => {
  1637. // $.gm_remain_focus_on_mousedown = 0;
  1638. // callback
  1639. });
  1640.  
  1641. $.gm_status_fn("gm_native_video_audio_contextmenu", "To Enable Native Video Audio Context Menu", "To Disable Native Video Audio Context Menu", () => {
  1642.  
  1643. })
  1644.  
  1645. }
  1646.  
  1647. if (typeof originalFocusFn === 'function' && HTMLElement.prototype.focus === originalFocusFn && originalFocusFn.length === 0) {
  1648. const f = HTMLElement.prototype.focus = function () {
  1649. if (focusNotAllowedUntil && $.gm_remain_focus_on_mousedown && focusNotAllowedUntil > Date.now()) return;
  1650. return originalFocusFn.apply(this, arguments);
  1651. }
  1652. f.toString = originalFocusFn.toString.bind(originalFocusFn);
  1653. }
  1654.  
  1655.  
  1656. })();