-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtelegram-web.user.js
37 lines (32 loc) · 1007 Bytes
/
telegram-web.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// ==UserScript==
// @name Telegram Web tweak
// @namespace https://github.com/lilydjwg/userscripts
// @description Telegram Web tweak
// @include https://web.telegram.org/*
// @version 0.1.1
// @run-at document-idle
// @grant none
// ==/UserScript==
(function() {
'use strict'
const observer = new MutationObserver(function(mutationList, _observer) {
for(let mutation of mutationList) {
if(mutation.type == 'childList') {
for(let node of mutation.addedNodes) {
if(node.classList.contains('confirm_modal_window')) {
const link = node.querySelector('[name="url"] > strong')
if(link) {
const linkParent = link.parentNode
const a = document.createElement('a')
a.target = '_blank'
a.href = link.textContent
a.appendChild(link)
linkParent.appendChild(a)
}
}
}
}
}
})
observer.observe(document.body, { childList: true })
})()