-
Notifications
You must be signed in to change notification settings - Fork 0
/
popup.tsx
26 lines (20 loc) · 872 Bytes
/
popup.tsx
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
async function getIndexPopup() {
const tabs = await chrome.tabs.query({ active: true, currentWindow: true });
const current_tab_url = tabs[0]?.url;
console.log(current_tab_url);
const cleaned_current_tab_url_without_utm = current_tab_url?.replace(/(utm_[^&]+&?)/g, "");
const domain = cleaned_current_tab_url_without_utm?.split("/")[2].replace(/^(www|m|mail|forum)\./, '');
const q = encodeURIComponent(cleaned_current_tab_url_without_utm);
const filters = encodeURIComponent(JSON.stringify({
"domainFilterType": "exclude",
"timeFilterOption": "any_time",
"activeTabFilter": "all",
"excludeDomains": [domain]
}));
const redirect_url = `https://metaphor.systems/search?q=${q}&filters=${filters}`;
if (cleaned_current_tab_url_without_utm) {
window.open(redirect_url, "_blank");
}
return null;
}
export default getIndexPopup;