-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathpopup.js
More file actions
178 lines (157 loc) · 6.16 KB
/
Copy pathpopup.js
File metadata and controls
178 lines (157 loc) · 6.16 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
// Netflix 4K Popup Script
document.addEventListener('DOMContentLoaded', async () => {
// Detect browser
const detectBrowser = () => {
const ua = navigator.userAgent;
if (ua.includes('Edg/')) {
// Extract Edge version
const match = ua.match(/Edg\/(\d+)/);
const version = match ? parseInt(match[1]) : 0;
const can4K = version >= 118;
return {
name: 'Edge',
version,
drm: 'PlayReady 3.0',
can4K,
reason: can4K ? 'Hardware DRM via Windows' : `Need Edge 118+, you have ${version}`
};
}
if (ua.includes('Firefox')) return {
name: 'Firefox',
version: 0,
drm: 'Widevine L3',
can4K: false,
reason: 'No PlayReady access'
};
if (ua.includes('Brave')) return {
name: 'Brave',
version: 0,
drm: 'Widevine L3',
can4K: false,
reason: 'No PlayReady access'
};
if (ua.includes('Chrome')) return {
name: 'Chrome',
version: 0,
drm: 'Widevine L3',
can4K: false,
reason: 'No PlayReady access'
};
if (ua.includes('Safari') && !ua.includes('Chrome')) return {
name: 'Safari',
version: 0,
drm: 'FairPlay',
can4K: true,
reason: 'macOS hardware DRM'
};
return {
name: 'Unknown',
version: 0,
drm: 'Unknown',
can4K: false,
reason: 'Unknown browser'
};
};
// Get display info
const getDisplayInfo = () => {
const realWidth = window.screen.width;
const realHeight = window.screen.height;
const is4K = realWidth >= 3840 || realHeight >= 2160;
return {
resolution: `${realWidth}x${realHeight}`,
is4K,
spoofed: '3840x2160'
};
};
// Update UI elements
const browser = detectBrowser();
const display = getDisplayInfo();
// Browser
const browserEl = document.getElementById('browser');
const browserText = browser.version ? `${browser.name} ${browser.version}` : browser.name;
browserEl.textContent = browserText;
browserEl.className = 'capability-value ' + (browser.can4K ? 'good' : 'warning');
// DRM (updated to show PlayReady vs Widevine)
const widevineEl = document.getElementById('widevine');
widevineEl.textContent = browser.drm;
widevineEl.className = 'capability-value ' + (browser.can4K ? 'good' : 'warning');
// Display
const displayEl = document.getElementById('display');
displayEl.textContent = display.resolution + (display.is4K ? '' : ' (spoofed)');
displayEl.className = 'capability-value ' + (display.is4K ? 'good' : 'warning');
// HDCP
document.getElementById('hdcp').className = 'capability-value good';
// Update verdict
const verdictCard = document.getElementById('verdictCard');
const verdictIcon = document.getElementById('verdictIcon');
const verdictText = document.getElementById('verdictText');
if (browser.can4K) {
verdictCard.className = 'verdict-card can-4k';
verdictIcon.textContent = '✓';
verdictIcon.style.color = '#46d369';
verdictText.innerHTML = '<strong>Your setup supports 4K!</strong><br>' +
browser.name + ' uses ' + browser.drm + ' (hardware DRM). ' +
'Make sure you have the HEVC extension from Microsoft Store installed.';
} else {
verdictCard.className = 'verdict-card no-4k';
verdictIcon.textContent = '!';
verdictIcon.style.color = '#f5c518';
if (browser.name === 'Edge' && browser.version < 118) {
verdictText.innerHTML = '<strong>Update Edge Required</strong><br>' +
'You need Edge 118 or later for 4K. You have version ' + browser.version + '. ' +
'Update at <code>edge://settings/help</code>';
} else {
verdictText.innerHTML = '<strong>Browser limited to 1080p</strong><br>' +
browser.name + ' uses ' + browser.drm + ' (software DRM). Netflix requires PlayReady 3.0 for 4K. ' +
'Use Microsoft Edge 118+ on Windows for 4K.';
}
}
// Check if we're on Netflix and get playback stats
const updateStatus = async () => {
try {
const [tab] = await chrome.tabs.query({ active: true, currentWindow: true });
if (!tab?.url?.includes('netflix.com')) {
setStatus('yellow', 'Extension Ready', 'Open Netflix to start watching');
document.getElementById('statsCard').style.display = 'none';
return;
}
const stats = await chrome.storage.local.get([
'playbackActive',
'currentResolution',
'currentBitrate',
'currentCodec',
'isHDR',
'lastUpdated'
]);
const isRecent = stats.lastUpdated && (Date.now() - stats.lastUpdated) < 10000;
if (stats.playbackActive && isRecent) {
const is4K = stats.currentResolution?.includes('3840') || stats.currentResolution?.includes('2160');
if (is4K) {
setStatus('green', '4K Active', 'Streaming in Ultra HD');
} else {
setStatus('yellow', 'Playing', stats.currentResolution || 'Detecting...');
}
document.getElementById('statsCard').style.display = 'block';
document.getElementById('resolution').textContent = stats.currentResolution || '--';
document.getElementById('resolution').className = 'stat-value' + (is4K ? '' : ' warning');
const bitrateNum = stats.currentBitrate ? (stats.currentBitrate / 1000).toFixed(1) : '--';
document.getElementById('bitrate').textContent = bitrateNum !== '--' ? bitrateNum + ' Mbps' : '--';
document.getElementById('codec').textContent = stats.currentCodec?.toUpperCase() || '--';
document.getElementById('hdr').textContent = stats.isHDR ? 'Yes' : 'No';
} else {
setStatus('green', 'Ready on Netflix', 'Play something to see stats');
document.getElementById('statsCard').style.display = 'none';
}
} catch (e) {
console.error('Error updating status:', e);
setStatus('gray', 'Unable to detect', 'Reload Netflix and try again');
}
};
const setStatus = (color, label, detail) => {
document.getElementById('statusIndicator').className = 'status-indicator ' + color;
document.getElementById('statusLabel').textContent = label;
document.getElementById('statusDetail').textContent = detail;
};
await updateStatus();
setInterval(updateStatus, 2000);
});