e-hentai auto hyperlink

e-hentai auto convert urls in gallery comments into hyperlinks

ของเมื่อวันที่ 04-06-2022 ดู เวอร์ชันล่าสุด

  1. // ==UserScript==
  2. // @name e-hentai auto hyperlink
  3. // @namespace https://greasyfork.org/scripts/441145
  4. // @version 1.2
  5. // @description e-hentai auto convert urls in gallery comments into hyperlinks
  6. // @author fmnijk
  7. // @match https://e-hentai.org/*
  8. // @icon https://www.google.com/s2/favicons?domain=e-hentai.org
  9. // @grant none
  10. // @run-at document-end
  11. // @license MIT
  12. // ==/UserScript==
  13.  
  14. /* $ and $$ */
  15. const $ = document.querySelector.bind(document);
  16. const $$ = document.querySelectorAll.bind(document);
  17.  
  18. /* main function */
  19. (window.onload = function() {
  20. 'use strict';
  21.  
  22. const comments = $$(".c6");
  23.  
  24. comments.forEach(function(comment){
  25. const before = comment.innerHTML;
  26.  
  27. const after = before.replace(/(<a href=")?((https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)))(">(.*)<\/a>)?/gi, function () {
  28. return '<a href="' + arguments[2] + '">' + (arguments[7] || arguments[2]) + '</a>'
  29. });
  30.  
  31. comment.innerHTML = after;
  32. });
  33. })();