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

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

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

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