telegram 速連2

telegram code block 中的 url 轉為超連結

目前为 2024-02-01 提交的版本。查看 最新版本

// ==UserScript==
// @name         telegram 速連2
// @namespace    https://tampermonkey.net/
// @version      1.0
// @description  telegram code block 中的 url 轉為超連結
// @author       Bee10301
// @match        https://web.telegram.org/a/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=web.telegram.org
// @grant        none
// @license      GNU GPLv3
// ==/UserScript==
/*jshint esversion: 6 */

(function() {
    'use strict';
    window.onload = () => {
    document.addEventListener("click", (event) => {
        const target = event.target;
        if (target.matches("code.text-entity-code.clickable")&& target.innerHTML.match(/(https?:\/\/[^\s]+)/)[0]) {
          window.open(`${target.innerHTML}`, "_blank");
        }
      });
  };

})();