-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpopup.js
More file actions
54 lines (51 loc) · 2.05 KB
/
Copy pathpopup.js
File metadata and controls
54 lines (51 loc) · 2.05 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
document.addEventListener('DOMContentLoaded', function() {
// Lógica do botão de filtro
const filterBtn = document.getElementById('filterBtn');
if (filterBtn) {
filterBtn.addEventListener('click', async () => {
const city = document.getElementById('cityInput').value;
const [tab] = await chrome.tabs.query({ active: true, currentWindow: true });
if (tab.id) {
chrome.tabs.sendMessage(tab.id, { action: "filterCity", city: city }, (response) => {
if (chrome.runtime.lastError) {
document.getElementById('status').innerText = "Erro: Recarregue a página do Facebook.";
} else {
document.getElementById('status').innerText = response ? response.status : "Filtro enviado!";
}
});
}
});
}
// Lógica do botão de recentes
const recentBtn = document.getElementById('recentBtn');
if (recentBtn) {
recentBtn.addEventListener('click', async () => {
const [tab] = await chrome.tabs.query({ active: true, currentWindow: true });
if (tab.id) {
chrome.tabs.sendMessage(tab.id, { action: "sortByRecent" }, () => {
if (chrome.runtime.lastError) {
document.getElementById('status').innerText = "Erro: Tente recarregar a página.";
} else {
document.getElementById('status').innerText = "Ordenando...";
}
});
}
});
}
// Lógica do botão limpar
const clearBtn = document.getElementById('clearBtn');
if (clearBtn) {
clearBtn.addEventListener('click', async () => {
const [tab] = await chrome.tabs.query({ active: true, currentWindow: true });
if (tab.id) {
chrome.tabs.sendMessage(tab.id, { action: "clearFilter" }, () => {
if (chrome.runtime.lastError) {
document.getElementById('status').innerText = "Erro: Tente recarregar a página.";
} else {
document.getElementById('status').innerText = "Filtros limpos.";
}
});
}
});
}
});