-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfilter-editor.js
More file actions
49 lines (42 loc) · 1.6 KB
/
Copy pathfilter-editor.js
File metadata and controls
49 lines (42 loc) · 1.6 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
"use strict";
// comment to debug
console.log = function () { }
async function sendMessageToBlindTabs(text) {
const tabs = await chrome.tabs.query({ 'url': "*://*.teamblind.com/*" });
tabs.forEach(async (tab) => {
console.log('handling tab', tab)
await chrome.tabs.sendMessage(tab.id, text);
});
}
chrome.storage.local.get('blindFilterText').then((result) => {
console.log('Value currently is ' + result.blindFilterText);
document.getElementById("message").innerHTML = result.blindFilterText || ''
});
document.getElementById("button").onclick = async () => {
await sendMessageToBlindTabs(document.getElementById("message").value);
await chrome.storage.local.set({ 'blindFilterText': document.getElementById("message").value });
console.log('Setting ' + document.getElementById("message").value)
};
// Get the current tab ID when popup opens
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
const currentTabId = tabs[0].id;
fetchContentMessages(currentTabId);
setInterval(() => fetchContentMessages(currentTabId))
});
function fetchContentMessages(tabId) {
// Request data from background script
chrome.runtime.sendMessage(
{ type: "GET_CONTENT_DATA", tabId: tabId },
function (response) {
displayMessages(response);
}
);
}
function displayMessages(response) {
const container = document.getElementById('blocked-label');
if (response && response.data) {
// Clear container
container.textContent = ''
container.textContent += `Blocked ${response.data.data} posts`
}
}