-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground.js
More file actions
26 lines (23 loc) · 741 Bytes
/
Copy pathbackground.js
File metadata and controls
26 lines (23 loc) · 741 Bytes
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
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
if (message.limitReached) {
console.log("Shorts limit reached. Activating blocking rule...");
// Enable the rule
chrome.declarativeNetRequest.updateEnabledRulesets(
{
enableRulesetIds: ["blockShortsRules"]
},
() => {
console.log("Shorts blocking rule enabled.");
}
);
// Close any Shorts tab
chrome.tabs.query({}, (tabs) => {
for (let tab of tabs) {
if (tab.url && tab.url.includes("youtube.com/shorts/")) {
console.log("Closing Shorts tab:", tab.url);
chrome.tabs.remove(tab.id);
}
}
});
}
});