-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpopup.js
More file actions
29 lines (29 loc) · 1.42 KB
/
Copy pathpopup.js
File metadata and controls
29 lines (29 loc) · 1.42 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
document.addEventListener('DOMContentLoaded', function() {
chrome.tabs.query({ active: true, currentWindow: true }, function(tabs) {
if (tabs.length > 0) {
chrome.scripting.executeScript(
{
target: { tabId: tabs[0].id },
files: ['content.js']
},
() => {
if (chrome.runtime.lastError) {
document.getElementById('theme-name').textContent = 'Error injecting script: ' + chrome.runtime.lastError.message;
} else {
chrome.tabs.sendMessage(tabs[0].id, { action: "getInfos" }, function(response) {
if (chrome.runtime.lastError) {
document.getElementById('theme-name').textContent = 'Error sending message: ' + chrome.runtime.lastError.message;
} else if (response && response.infos) {
document.getElementById('theme-name').innerHTML = response.infos;
} else {
document.getElementById('theme-name').textContent = 'Error displaying response.';
}
});
}
}
);
} else {
document.getElementById('theme-name').textContent = 'No active tab found.';
}
});
});