mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-08-10 23:27:46 +02:00
Block notifications
This commit is contained in:
39
dist/better-xcloud.lite.user.js
vendored
39
dist/better-xcloud.lite.user.js
vendored
@@ -269,6 +269,9 @@ var SUPPORTED_LANGUAGES = {
|
||||
"zh-CN": "中文(简体)",
|
||||
"zh-TW": "中文(繁體)"
|
||||
}, Texts = {
|
||||
notifications: "Notifications",
|
||||
invites: "Invites",
|
||||
achievements: "Achievements",
|
||||
chat: "Chat",
|
||||
"friends-followers": "Friends and followers",
|
||||
byog: "Stream your own game",
|
||||
@@ -1716,7 +1719,9 @@ class GlobalSettingsStorage extends BaseSettingsStore {
|
||||
multipleOptions: {
|
||||
chat: t("chat"),
|
||||
friends: t("friends-followers"),
|
||||
byog: t("byog")
|
||||
byog: t("byog"),
|
||||
"notifications-invites": t("notifications") + ": " + t("invites"),
|
||||
"notifications-achievements": t("notifications") + ": " + t("achievements")
|
||||
}
|
||||
},
|
||||
"userAgent.profile": {
|
||||
@@ -2006,6 +2011,10 @@ function clearAllData() {
|
||||
} catch (e) {}
|
||||
alert(t("clear-data-success"));
|
||||
}
|
||||
function blockAllNotifications() {
|
||||
let blockFeatures = getPref("block.features");
|
||||
return ["friends", "notifications-achievements", "notifications-invites"].every((value) => blockFeatures.includes(value));
|
||||
}
|
||||
class SoundShortcut {
|
||||
static adjustGainNodeVolume(amount) {
|
||||
if (!getPref("audio.volume.booster.enabled")) return 0;
|
||||
@@ -5627,29 +5636,19 @@ async function patchIceCandidates(request, consoleAddrs) {
|
||||
}
|
||||
function interceptHttpRequests() {
|
||||
let BLOCKED_URLS = [];
|
||||
if (getPref("block.tracking")) clearAllLogs(), BLOCKED_URLS = BLOCKED_URLS.concat([
|
||||
"https://arc.msn.com",
|
||||
"https://browser.events.data.microsoft.com",
|
||||
"https://dc.services.visualstudio.com",
|
||||
"https://2c06dea3f26c40c69b8456d319791fd0@o427368.ingest.sentry.io",
|
||||
"https://mscom.demdex.net"
|
||||
]);
|
||||
if (getPref("block.tracking")) clearAllLogs(), BLOCKED_URLS.push("https://arc.msn.com", "https://browser.events.data.microsoft.com", "https://dc.services.visualstudio.com", "https://2c06dea3f26c40c69b8456d319791fd0@o427368.ingest.sentry.io", "https://mscom.demdex.net");
|
||||
let blockFeatures2 = getPref("block.features");
|
||||
if (blockFeatures2.includes("chat")) BLOCKED_URLS = BLOCKED_URLS.concat([
|
||||
"https://xblmessaging.xboxlive.com/network/xbox/users/me/inbox"
|
||||
]);
|
||||
if (blockFeatures2.includes("friends")) BLOCKED_URLS = BLOCKED_URLS.concat([
|
||||
"https://peoplehub.xboxlive.com/users/me/people/social",
|
||||
"https://peoplehub.xboxlive.com/users/me/people/recommendations"
|
||||
]);
|
||||
if (blockFeatures2.includes("chat")) BLOCKED_URLS.push("https://xblmessaging.xboxlive.com/network/xbox/users/me/inbox");
|
||||
if (blockFeatures2.includes("friends")) BLOCKED_URLS.push("https://peoplehub.xboxlive.com/users/me/people/social", "https://peoplehub.xboxlive.com/users/me/people/recommendations");
|
||||
if (blockAllNotifications()) BLOCKED_URLS.push("https://notificationinbox.xboxlive.com/");
|
||||
let xhrPrototype = XMLHttpRequest.prototype, nativeXhrOpen = xhrPrototype.open, nativeXhrSend = xhrPrototype.send;
|
||||
xhrPrototype.open = function(method, url) {
|
||||
return this._url = url, nativeXhrOpen.apply(this, arguments);
|
||||
}, xhrPrototype.send = function(...arg) {
|
||||
for (let blocked of BLOCKED_URLS)
|
||||
if (this._url.startsWith(blocked)) {
|
||||
if (blocked === "https://dc.services.visualstudio.com") window.setTimeout(clearAllLogs, 1000);
|
||||
return !1;
|
||||
for (let url of BLOCKED_URLS)
|
||||
if (this._url.startsWith(url)) {
|
||||
if (url === "https://dc.services.visualstudio.com") window.setTimeout(clearAllLogs, 1000);
|
||||
return BxLogger.warning("Blocked URL", url), !1;
|
||||
}
|
||||
return nativeXhrSend.apply(this, arguments);
|
||||
};
|
||||
@@ -5671,7 +5670,7 @@ function interceptHttpRequests() {
|
||||
window.BX_FETCH = window.fetch = async (request, init) => {
|
||||
let url = typeof request === "string" ? request : request.url;
|
||||
for (let blocked of BLOCKED_URLS)
|
||||
if (url.startsWith(blocked)) return new Response('{"acc":1,"webResult":{}}', {
|
||||
if (url.startsWith(blocked)) return BxLogger.warning("Blocked URL", url), new Response('{"acc":1,"webResult":{}}', {
|
||||
status: 200,
|
||||
statusText: "200 OK"
|
||||
});
|
||||
|
Reference in New Issue
Block a user