forked from mudachyo/TapSwap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtapswap-web.user.js
More file actions
71 lines (62 loc) · 2.67 KB
/
tapswap-web.user.js
File metadata and controls
71 lines (62 loc) · 2.67 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// ==UserScript==
// @name TapSwap web
// @namespace http://tampermonkey.net/
// @version 1.2
// @description Running TapSwap in a browser
// @author mudachyo
// @match *://app.tapswap.club/*
// @grant none
// @icon https://www.softportal.com/en/scr/1089/icons/icon_src.png
// @downloadURL https://github.com/mudachyo/TapSwap/raw/main/tapswap-web.user.js
// @updateURL https://github.com/mudachyo/TapSwap/raw/main/tapswap-web.user.js
// @homepage https://github.com/mudachyo/TapSwap
// ==/UserScript==
(function() {
'use strict';
// Функция для замены URL скрипта
function replaceScriptUrl() {
// URL-адрес для замены
const oldUrl = 'https://telegram.org/js/telegram-web-app.js';
const newUrl = 'https://ktnff.tech/universal/telegram-web-app.js';
// Получаем все теги <script> на странице
const scripts = document.getElementsByTagName('script');
for (let script of scripts) {
// Проверяем, содержит ли src один из URL-адресов для замены
if (script.src === oldUrl) {
// Создаем новый тег <script> с новым URL
const newScript = document.createElement('script');
newScript.src = newUrl;
newScript.type = 'text/javascript';
// Заменяем старый тег на новый
script.parentNode.replaceChild(newScript, script);
console.log('Script URL replaced:', newScript.src);
}
}
}
// Функция для перезагрузки страницы
function checkAndReload() {
if (document.querySelector('div._leaveContainer_rxbn1_1')) {
console.log('Class _leaveContainer_rxbn1_1 found, reloading page.');
location.reload();
}
}
// Наблюдатель за изменениями в DOM
const observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
if (mutation.addedNodes.length) {
replaceScriptUrl();
checkAndReload();
}
});
});
// Настройки наблюдателя
const config = {
childList: true,
subtree: true
};
// Начинаем наблюдение за изменениями в DOM
observer.observe(document.body, config);
// Первоначальный запуск замены URL и проверка на наличие класса
replaceScriptUrl();
checkAndReload();
})();