-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontent_injection.js
More file actions
70 lines (66 loc) · 3.26 KB
/
Copy pathcontent_injection.js
File metadata and controls
70 lines (66 loc) · 3.26 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
// content_injection.js
'use strict';
(() => {
// This self-executing function contains the code previously injected by content.js
// This is the Manifest V3 compatible way to run code in the page's MAIN world.
// Function from content.js: перехватитьФункции()
// Function from content.js: interceptFunctions()
let _лНеПерехватывать = false;
// let _bDoNotIntercept = false;
window.addEventListener('tw5-неперехватывать', () => {
// window.addEventListener('tw5-donotintercept', () => {
_лНеПерехватывать = true;
// _bDoNotIntercept = true;
});
const oTitleDescriptor = Object.getOwnPropertyDescriptor(Document.prototype, 'title');
Object.defineProperty(document, 'title', {
configurable: oTitleDescriptor.configurable,
enumerable: oTitleDescriptor.enumerable,
get() {
return oTitleDescriptor.get.call(this);
},
set(title) {
if (_лНеПерехватывать) {
// if (_bDoNotIntercept) {
oTitleDescriptor.set.call(this, title);
} else if (this.documentElement.hasAttribute('data-tw5-перенаправление')) {} else {
// } else if (this.documentElement.hasAttribute('data-tw5-redirect')) {} else {
oTitleDescriptor.set.call(this, title);
window.dispatchEvent(new CustomEvent('tw5-изменензаголовок'));
// window.dispatchEvent(new CustomEvent('tw5-titlechanged'));
}
}
});
const fPushState = history.pushState;
history.pushState = function (state, title) {
if (_лНеПерехватывать) {
// if (_bDoNotIntercept) {
fPushState.apply(this, arguments);
} else if (document.documentElement.hasAttribute('data-tw5-перенаправление')) {} else {
// } else if (document.documentElement.hasAttribute('data-tw5-redirect')) {} else {
const сБыло = location.pathname;
// const sWas = location.pathname;
fPushState.apply(this, arguments);
if (сБыло !== location.pathname) {
// if (sWas !== location.pathname) {
oTitleDescriptor.set.call(document, 'Twitch');
window.dispatchEvent(new CustomEvent('tw5-pushstate'));
}
}
};
// Function from content.js: разрешитьРаботуЧата()
// Function from content.js: allowChatToWork()
const fGetItem = Storage.prototype.getItem;
Storage.prototype.getItem = function (сИмя) {
// Storage.prototype.getItem = function (sName) {
let сЗначение = fGetItem.apply(this, arguments);
// let sValue = fGetItem.apply(this, arguments);
if (сИмя === 'TwitchCache:Layout' && сЗначение) {
// if (sName === 'TwitchCache:Layout' && sValue) {
сЗначение = сЗначение.replace('"isRightColumnClosedByUserAction":true', '"isRightColumnClosedByUserAction":false');
// sValue = sValue.replace('"isRightColumnClosedByUserAction":true', '"isRightColumnClosedByUserAction":false');
}
return сЗначение;
// return sValue;
};
})();