fix(browser-extension): background and content minor bugs

This commit is contained in:
wanhose 2022-05-17 17:04:50 +02:00
parent 5f3d346eb8
commit b1b9b092b2
2 changed files with 6 additions and 4 deletions

View File

@ -93,8 +93,8 @@ const query = async (key, callback) => {
const queryTab = (callback) => {
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
callback({
id: tabs[0].id,
hostname: new URL(tabs[0].url).hostname,
id: tabs[0]?.id,
hostname: new URL(tabs[0].url).hostname.split('.').slice(-2).join('.'),
});
});
};
@ -112,7 +112,7 @@ const report = () => {
if (tab) {
fetch(`${apiUrl}/report/`, {
body: JSON.stringify({
text: `There's a problem with ${tab.url} using ${userAgent} in CDM ${version}`,
html: `<b>Browser:</b> ${userAgent}<br/><b>Site:</b> ${tab.url}<br/> <b>Version:</b> ${version}`,
to: 'wanhose.development@gmail.com',
subject: 'Cookie Dialog Monster Report',
}),

View File

@ -78,7 +78,9 @@ const check = (node) =>
const clean = (nodes) => {
if (selectors.length) {
nodes.filter(check).forEach((node) => (node.outerHTML = ''));
nodes.filter(check).forEach((node) => {
if (node.parentElement) node.outerHTML = '';
});
}
};