簡單小腳本,當對話中 code block
吻合https,點擊可開啟新視窗。
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");
}
});
};
}