Skip to content

Commit

Permalink
Fix a bug where Firefox users were not getting the consent flow if th…
Browse files Browse the repository at this point in the history
…ey updated from non-listed versions (#384)

* [fix] check if the previous version is below the minimum version with a consent popup

I made the minimum this version just in case other users have the same issue as #383

* [fix] add text about the consent page coming up again

* [fix] skip consent script in non-FF FF-likes, add default value for canLoad flag
  • Loading branch information
rougetimelord authored Dec 6, 2024
1 parent 05b844f commit c7b133f
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 7 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "blue-blocker",
"version": "0.4.13",
"version": "0.4.14",
"author": "DanielleMiu",
"description": "Blocks all Twitter Blue verified users on twitter.com",
"type": "module",
Expand Down
29 changes: 26 additions & 3 deletions src/background/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ api.runtime.onStartup.addListener(() => {
// @ts-ignore
api.runtime?.getBrowserInfo().then(info => {
if(info.name == 'Firefox') {
api.storage.local.get("canLoad").then( val => {
api.storage.local.get({"canLoad": false}).then( val => {
if (!val) {
registerConsentScript();
}
Expand All @@ -118,26 +118,49 @@ api.runtime.onStartup.addListener(() => {
}
});
}
else {
// In a FF based browser, that isn't FF
registerConsentScript();
}
})
}
catch {
console.debug(logstr, "not running on Firefox!");
}
})

const consentRequiredVersions = ['0.3.5']
const minConsentVersion = '0.4.14';

function isBelowMinVer(newVersion: string, minVersion: string) {
const [newMajor, newMinor, newPatch] = String(newVersion).split('.').map(Number);
const [minMajor, minMinor, minPatch] = String(minVersion).split('.').map(Number);

if (newMajor !== minMajor) {
return newMajor < minMajor;
}

if (newMinor !== minMinor) {
return newMinor < minMinor;
}

return newPatch < minPatch;
}

api.runtime.onInstalled.addListener( ({reason, previousVersion}) => {
try {
/** @ts-ignore I hate that I have to use FF specific APIs to detect FF :)))*/
api.runtime?.getBrowserInfo().then(info => {
if (info.name == 'Firefox') {
if(reason == 'install' || (reason == 'update' && consentRequiredVersions.includes(previousVersion as string))) {
if(reason == 'install' || (reason == 'update' && isBelowMinVer(previousVersion as string, minConsentVersion))) {
registerConsentScript();
const url = api.runtime.getURL('src/pages/consent/index.html');
api.tabs.create({url})
}
}
else {
// In a FF based browser, that isn't FF
registerConsentScript();
}
})
}
catch {
Expand Down
2 changes: 1 addition & 1 deletion src/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { defineManifest } from '@crxjs/vite-plugin';
export default defineManifest({
name: 'Blue Blocker',
description: 'Blocks all Twitter Blue verified users on twitter.com',
version: '0.4.13',
version: '0.4.14',
manifest_version: 3,
icons: {
'128': 'icon/icon-128.png',
Expand Down
1 change: 1 addition & 0 deletions src/pages/consent/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ <h1>Collection of Data Disclosure</h1>
<p>All data that Blue Blocker collects, stores, uses, and transmits is mandatory for the function of the extension Because the collection, storage, usage, and transmission of personal data is necessary for the function of this extension, refusing will cause the extension to be uninstalled</p>
<br>
<p>To read the full privacy policy visit the <a href="https://addons.mozilla.org/en-US/firefox/addon/blue-blocker/privacy/" target="_blank" rel="noopener noreferrer">Firefox addons page</a></p>
<p>You might be shown this screen again in the future; for example if there is an update in Firefox's policies.</p>
<br>
<p>Having read the above disclosure, do you consent to Blue Blocker collecting, storing, using, and transmitting your personal data?</p>
<div class="inputs">
Expand Down

0 comments on commit c7b133f

Please sign in to comment.