-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcontent.js
More file actions
38 lines (37 loc) · 1.3 KB
/
content.js
File metadata and controls
38 lines (37 loc) · 1.3 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
// === хелперы ===
(function() {
window.changeHashPlatform = () => {
var lochash = location.hash.toString();
if (lochash.indexOf('tgWebAppPlatform=weba') !== -1) {
lochash = lochash.replaceAll("tgWebAppPlatform=weba", "tgWebAppPlatform=android");
} else if (lochash.indexOf('tgWebAppPlatform=web') !== -1) {
lochash = lochash.replaceAll("tgWebAppPlatform=web", "tgWebAppPlatform=android");
}
location.hash = lochash;
if (index == 0) {
location.reload();
index = 1;
}
if (code != "") {
eval(code);
}
};
window.changeHashPlatform();
addEventListener("hashchange", (event) => {
window.changeHashPlatform();
});
})();
var index = 0;
var code = "";
chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) {
// Проверка, содержит ли сообщение JavaScript код
if (message && message.code) {
try {
code = message.code;
// Выполнение JavaScript кода в контексте веб-страницы
eval(message.code);
} catch (error) {
console.error('Ошибка выполнения JavaScript кода:', error);
}
}
});