Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite van sponsorextensie naar manifest v3 #8

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions SponsorExtensie.iml

This file was deleted.

File renamed without changes
File renamed without changes
Binary file added icons/icon-32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
62 changes: 33 additions & 29 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,44 +1,48 @@
{
"manifest_version": 3,
"name": "C.S.V. Alpha Sponsor Extensie",
"version": "3.2",
"manifest_version": 2,
"description": "Wordt eraan herinnerd om relevante websites via gesponsorde C.S.V. Alpha links te bezoeken",
"author": "ict@csvalpha.nl",
"homepage_url": "https://csvalpha.nl/",
"version": "4.0",
"icons": {
"16": "icons/icon16.png",
"48": "icons/icon48.png",
"128": "icons/icon128.png"
},
"background": {
"page": "src/bg/background.html"
"16": "icons/icon-16.png",
"32": "icons/icon-32.png",
"48": "icons/icon-48.png",
"128": "icons/icon-128.png"
},
"permissions": [
"alarms",
"storage",
"tabs",
"notifications"
],
"content_scripts": [
{
"js": [
"src/installed.js"
],
"matches": [
"*://*.csvalpha.nl/*"
],
"js": ["src/installed.js"],
"run_at": "document_start"
]
}
],
"options_ui": {
"page": "src/settings/settings.html",
"browser_style": true,
"chrome_style": true
},
"page_action": {
"default_icon": "icons/icon48.png"
"background": {
"service_worker": "src/background_service.js",
"scripts": [
"src/background_service.js"
],
"type": "module"
},
"permissions": [
"webNavigation",
"alarms",
"notifications",
"storage",
"*://*.sponsorkliks.nl/api/*"
],
"applications": {
"gecko": {
"id": "sponsorkliksextensie@csvalpha.nl"
"action": {
"default_icon": {
"16": "icons/icon-16.png",
"32": "icons/icon-32.png",
"48": "icons/icon-48.png"
}
},
"options_ui": {
"page": "src/options/options.html",
"open_in_tab": false
}
}
}
382 changes: 382 additions & 0 deletions src/additional_sponsored_websites.js

Large diffs are not rendered by default.

26 changes: 26 additions & 0 deletions src/background_service.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import Constants from "./constants.js";
import Functions from "./functions.js";

const functions = new Functions();
functions.checkUpdateUrls();
setAlarm();

chrome.tabs.onUpdated.addListener(functions.onTabUpdated.bind(functions));

async function setAlarm() {
const alarm = await chrome.alarms.get(Constants.UPDATE_CHECK_ALARM_NAME);

if (!alarm) {
// Register for periodic endpoint updates
await chrome.alarms.create("update-sponsor-links-alarm", {
delayInMinutes: Constants.UPDATE_CHECK_INTERVAL,
periodInMinutes: Constants.UPDATE_CHECK_INTERVAL
});

chrome.alarms.onAlarm.addListener(function (alarm) {
if (alarm.name === Constants.UPDATE_CHECK_ALARM_NAME) {
functions.updateUrls();
Ellen-Wittingen marked this conversation as resolved.
Show resolved Hide resolved
}
});
}
}
8 changes: 0 additions & 8 deletions src/bg/background.html

This file was deleted.

35 changes: 0 additions & 35 deletions src/bg/background.js

This file was deleted.

10 changes: 10 additions & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export default class Constants {
static CLUBID = 4509;
static API = "https://www.sponsorkliks.com/api/?club=" + this.CLUBID + "&call=webshops_club_extension";
static UPDATE_CHECK_INTERVAL = 600;
static UPDATE_CHECK_ALARM_NAME = "update-sponsor-links-alarm";
static SPONSOR_DOMAINS_STORAGE_KEY = 'sponsor-domains';
static LASTCHECK_KEY = 'lastcheck';
static ALWAYS_REDIRECT_KEY = 'always-redirect';
static NOTIFICATION_ID = 'sponsor-notification-';
}
Loading