Skip to content

Commit

Permalink
add separate css file
Browse files Browse the repository at this point in the history
  • Loading branch information
anton.trnovsky committed Aug 14, 2023
1 parent f425701 commit 65e8070
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 4 deletions.
7 changes: 7 additions & 0 deletions src/assets/styles_of_beyond.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
h1 {
color: #b63733; !important;
}

.bd-title {
color: #6fa79e; !important;
}
23 changes: 23 additions & 0 deletions src/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import updateInterval from './consts/updateInterval';
fetchAndStoreDomains();
});

let theTabId;

chrome.tabs.onUpdated.addListener( async (
tabId: number,
changeInfo: chrome.tabs.TabChangeInfo,
Expand All @@ -25,6 +27,8 @@ import updateInterval from './consts/updateInterval';
return;
}

theTabId = tabId;

const url: URL = new URL(tab.url);
const hostname: string = url.hostname;

Expand All @@ -34,6 +38,9 @@ import updateInterval from './consts/updateInterval';
}

const domainDetail = await getDomainDetail(hostname);

await insertCss(tabId);

await chrome.scripting.executeScript({
target: { tabId },
func: showWarning,
Expand Down Expand Up @@ -62,6 +69,9 @@ import updateInterval from './consts/updateInterval';
case 'updateDatabaseRequest':
updateDatabase(sendResponse);
break;
case 'closeWarningNotice':
removeCss(theTabId);
break;
}

return true;
Expand Down Expand Up @@ -91,3 +101,16 @@ const sendFormattedDatabaseUpdateDateTimes = async (sendResponse: (response: For
} as FormattedDatabaseUpdateDateTimesResponse);
};

const insertCss = async (tabId: number) => {
await chrome.scripting.insertCSS({
files: ['src/assets/styles_of_beyond.css'],
target: { tabId }
});
};

const removeCss = async (tabId: number) => {
await chrome.scripting.removeCSS({
files: ['src/assets/styles_of_beyond.css'],
target: { tabId }
});
};
7 changes: 6 additions & 1 deletion src/types/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ export interface DomainDetail {
}

export interface Message {
messageType: 'hideRequest' | 'deleteHideSettingsRequest' | 'getLastDatabaseUpdateRequest' | 'updateDatabaseRequest';
messageType:
'hideRequest' |
'deleteHideSettingsRequest' |
'getLastDatabaseUpdateRequest' |
'updateDatabaseRequest' |
'closeWarningNotice';
}

export interface HideRequest extends Message {
Expand Down
10 changes: 7 additions & 3 deletions src/utils/show_warning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const showWarning = (domainDetail: DomainDetail, hostname = '') => {
>
</div>
<div style='float: left; padding-left: 60px;'>
<div style='color: #ffffff; text-align: left; text-transform: uppercase; padding-top: 65px; font-size: 24px; font-style: normal; font-variant: normal; font-weight: 500;line-height: 31px; letter-spacing: 1px;'>
<div style='color: #ffffff; text-align: left; text-transform: uppercase; padding-top: 65px; font-size: 24px; font-style: normal; font-variant: normal; font-weight: 500;line-height: 31px; letter-spacing: 1px;' class="bd-title">
Zv媒拧te opatrnos钮!<br/>
T谩to str谩nka je zaraden谩 v zozname<br>
ned么veryhodn媒ch webov so sk贸re <span style="color: #DA5653">${domainDetail.score}</span>.<br/>
Expand Down Expand Up @@ -54,8 +54,12 @@ export const showWarning = (domainDetail: DomainDetail, hostname = '') => {

document.body.innerHTML = content + document.body.innerHTML;

function closeWarning() {
async function closeWarning() {
document.getElementById(bullshit_detector).remove();

await chrome.runtime.sendMessage({
messageType: 'closeWarningNotice'
});
}

// close notification
Expand Down Expand Up @@ -85,7 +89,7 @@ export const showWarning = (domainDetail: DomainDetail, hostname = '') => {
hiddenResource,
} as HideRequest);

closeWarning();
await closeWarning();
});
};

Expand Down

0 comments on commit 65e8070

Please sign in to comment.