🏠 返回首頁 

Greasy Fork is available in English.

Selection and Copying Restorer (Universal)

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.

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