Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

Commit

Permalink
add localization and small tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
nitrog0d committed Sep 18, 2021
1 parent b2cc5d7 commit dca35b9
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 10 deletions.
8 changes: 8 additions & 0 deletions _locales/en/messages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extensionName": {
"message": "Brainly Blocker by nitro."
},
"extensionDescription": {
"message": "An extension that blocks some of brainly's ads and other stuff."
}
}
8 changes: 8 additions & 0 deletions _locales/pt_BR/messages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extensionName": {
"message": "Brainly Blocker por nitro."
},
"extensionDescription": {
"message": "Uma extensão que bloqueia alguns dos anúncios do brainly e outras coisas."
}
}
9 changes: 5 additions & 4 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
{
"name": "Brainly Blocker by nitro.",
"name": "__MSG_extensionName__",
"short_name": "Brainly Blocker",
"author": "nitro.",
"description": "An extension that blocks some of brainly's ads and other stuff.",
"version": "1.0.0",
"description": "__MSG_extensionDescription__",
"version": "1.0.1",
"manifest_version": 2,
"default_locale": "pt_BR",
"content_scripts": [
{
"js": [ "src/inject.js" ],
"matches": [ "*://brainly.com.br/tarefa/*", "*://brainly.com/question/*", "*://brainly.in/question/*" ],
"matches": [ "*://brainly.com.br/*", "*://brainly.com/*", "*://brainly.in/*" ],
"run_at": "document_idle"
}
],
Expand Down
18 changes: 12 additions & 6 deletions src/inject.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
// I swear. I tried every single way to listen to when local storage is changed in the same window but it doesn't work. This is my last idea, I tried.

// Set these to a REALLY (I mean it) far timestamp so it doesn't annoy us with popups
localStorage.setItem('registration-toplayer/expires', 2147483647000);
localStorage.setItem('offer-modal/timestamp', 2147483647000);
localStorage.setItem('welcome-payment-form/timestamp', 2147483647000);

// Loop through every key
Object.keys(localStorage).forEach((key) => {
// Remove every entry that starts with "flexible-tunnel", that's part of the ads
if (key.startsWith('flexible-funnel')) {
localStorage.removeItem(key);
}
// Set these to a REALLY (I mean it) far timestamp so it doesn't annoy us with popups
if (key === 'registration-toplayer/expires' || key === 'offer-modal/timestamp' || key === 'welcome-payment-form/timestamp') {
localStorage.setItem(key, 2147483647000);
}
});

// Remove annoying banner
const banner = document.getElementsByClassName('js-react-bottom-banner')[0];
if (banner) banner.parentNode.removeChild(banner);
const pathName = window.location.pathname;
if (pathName.startsWith('/tarefa') || pathName.startsWith('/question')) {
const banner = document.getElementsByClassName('js-react-bottom-banner')[0];
if (banner) banner.parentNode.removeChild(banner);
}

0 comments on commit dca35b9

Please sign in to comment.