-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathbackground.js
More file actions
73 lines (65 loc) · 1.92 KB
/
Copy pathbackground.js
File metadata and controls
73 lines (65 loc) · 1.92 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
72
73
// Netflix 4K - Background Service Worker
// Handles settings and stats storage for popup
console.log('[Netflix 4K] Background service worker loaded');
// Initialize on install
chrome.runtime.onInstalled.addListener((details) => {
console.log('[Netflix 4K] Extension installed:', details.reason);
// Set default settings
chrome.storage.local.set({
enabled: true,
maxBitrate: 16000,
forceHEVC: true,
forceVP9: true,
spoofHDCP: true,
// Stats (will be updated by content script)
playbackActive: false,
currentResolution: null,
currentBitrate: null,
currentCodec: null,
isHDR: false,
videoId: null,
lastUpdated: null
});
});
// Handle messages
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
if (message.type === 'getSettings') {
chrome.storage.local.get(null, (settings) => {
sendResponse(settings);
});
return true;
}
if (message.type === 'updateStats') {
// Update stats from content script
chrome.storage.local.set({
playbackActive: message.stats.playbackActive,
currentResolution: message.stats.currentResolution,
currentBitrate: message.stats.currentBitrate,
currentCodec: message.stats.currentCodec,
isHDR: message.stats.isHDR,
videoId: message.stats.videoId,
lastUpdated: Date.now()
});
return false;
}
if (message.type === 'log') {
console.log('[Netflix 4K]', message.data);
}
});
// Clear stats when tab is closed or navigates away from Netflix
chrome.tabs.onRemoved.addListener((tabId) => {
chrome.storage.local.set({
playbackActive: false,
currentResolution: null,
lastUpdated: null
});
});
chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
if (changeInfo.url && !changeInfo.url.includes('netflix.com')) {
chrome.storage.local.set({
playbackActive: false,
currentResolution: null,
lastUpdated: null
});
}
});