-
Notifications
You must be signed in to change notification settings - Fork 28
/
popup-wrapper.js
27 lines (24 loc) · 907 Bytes
/
popup-wrapper.js
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
chrome.tabs.query({active: true, currentWindow: true}, (tabs) => {
if (tabs[0] === undefined || !tabs[0].url.startsWith('https://www.youtube.com/')) {
const errorMessageSpan = document.querySelector('#extErrorMessage')
errorMessageSpan.textContent = 'You need to be on YouTube!'
return
}
chrome.scripting.executeScript({
target: {tabId: tabs[0].id},
// showPopup acutally toggles popup here
func: () => window.__PREVYOU_LOADED ? (showPopup(), true) : false,
}, results => {
if (!results[0].result) {
chrome.scripting.executeScript({
target: {tabId: tabs[0].id},
files: ['/content.js']
});
chrome.scripting.insertCSS({
target: {tabId: tabs[0].id},
files: ['/content.css']
})
}
window.close();
});
});