aaa
This commit is contained in:
parent
df14f2ea17
commit
ad332b4d47
2 changed files with 30 additions and 15 deletions
|
|
@ -5,11 +5,28 @@ chrome.action.onClicked.addListener((tab) => {
|
||||||
chrome.tabs.create({ active: true, url: chrome.runtime.getURL('settings.html') });
|
chrome.tabs.create({ active: true, url: chrome.runtime.getURL('settings.html') });
|
||||||
});
|
});
|
||||||
|
|
||||||
// REGISTER AN ALARM FOR DAILY UPDATE CHECK
|
// REGISTER AN ALARM FOR DAILY UPDATE CHECK (chatgpt cause I'm lazy and have to release Poly+ on February 8th aka today at the time of writing this)
|
||||||
|
// Calculate the milliseconds until the next 12 PM
|
||||||
|
/*
|
||||||
|
const now = new Date();
|
||||||
|
const msUntilNext12PM = new Date(
|
||||||
|
now.getFullYear(),
|
||||||
|
now.getMonth(),
|
||||||
|
now.getDate(),
|
||||||
|
12, // 12 PM hour
|
||||||
|
0, // 0 minutes
|
||||||
|
0 // 0 seconds
|
||||||
|
) - now;
|
||||||
|
|
||||||
|
// Convert milliseconds to minutes
|
||||||
|
const minutesUntilNext12PM = msUntilNext12PM / (1000 * 60);
|
||||||
|
|
||||||
|
// Create the alarm
|
||||||
chrome.alarms.create("PolyPlus-UpdateCheck", {
|
chrome.alarms.create("PolyPlus-UpdateCheck", {
|
||||||
periodInMinutes: 24 * 60,
|
periodInMinutes: 24 * 60, // 24 hours
|
||||||
when: Date.now() + (12 - new Date().getHours()) * 60 * 60 * 1000,
|
delayInMinutes: minutesUntilNext12PM, // Time until next 12 PM
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
|
|
||||||
// HANDLE ALARMS FIRING
|
// HANDLE ALARMS FIRING
|
||||||
chrome.alarms.onAlarm.addListener(function(alarm){
|
chrome.alarms.onAlarm.addListener(function(alarm){
|
||||||
|
|
@ -24,11 +41,18 @@ chrome.alarms.onAlarm.addListener(function(alarm){
|
||||||
.then(data => {
|
.then(data => {
|
||||||
if (data.version > Manifest.version) {
|
if (data.version > Manifest.version) {
|
||||||
console.log('Update available')
|
console.log('Update available')
|
||||||
chrome.notifications.create({
|
chrome.notifications.create("", {
|
||||||
type: "basic",
|
type: "basic",
|
||||||
iconUrl: chrome.runtime.getURL("icon.png"),
|
iconUrl: chrome.runtime.getURL("icon.png"),
|
||||||
title: "New Update Available",
|
title: "New Update Available",
|
||||||
message: "A new update is available for Poly+!",
|
message: "A new update is available for Poly+!",
|
||||||
|
}, function(notificationID) {
|
||||||
|
chrome.notifications.onClicked.addListener(function (id) {
|
||||||
|
if (id === notificationID) {
|
||||||
|
chrome.tabs.create({url: 'https://github.com/IndexingGitHub/PolyPlus', active: true})
|
||||||
|
chrome.notifications.clear(notificationID)
|
||||||
|
}
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
@ -63,15 +87,6 @@ chrome.contextMenus.create({
|
||||||
|
|
||||||
// HANDLE CONTEXT MENU ITEMS
|
// HANDLE CONTEXT MENU ITEMS
|
||||||
chrome.contextMenus.onClicked.addListener(function (info, tab){
|
chrome.contextMenus.onClicked.addListener(function (info, tab){
|
||||||
chrome.notifications.create({
|
|
||||||
type: "basic",
|
|
||||||
iconUrl: chrome.runtime.getURL("icon.png"),
|
|
||||||
title: "New Update Available",
|
|
||||||
message: "A new update is available for Poly+!",
|
|
||||||
}, function(id) {
|
|
||||||
console.log(id)
|
|
||||||
})
|
|
||||||
|
|
||||||
if (info.menuItemId === 'PolyPlus-CopyID') {
|
if (info.menuItemId === 'PolyPlus-CopyID') {
|
||||||
let ID = parseInt(info.linkUrl.split('/')[4])
|
let ID = parseInt(info.linkUrl.split('/')[4])
|
||||||
chrome.scripting
|
chrome.scripting
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@
|
||||||
"manifest_version": 3,
|
"manifest_version": 3,
|
||||||
"name": "Poly+",
|
"name": "Poly+",
|
||||||
"version": "1.0",
|
"version": "1.0",
|
||||||
"version_name": "Beta",
|
"version_name": "Public Beta",
|
||||||
"description": "This extension adds quality of life improvements and features to Polytoria's website. Created by Index",
|
"description": "Power-up your Polytoria experience with Poly+! Created by Index.",
|
||||||
"permissions": ["storage", "contextMenus", "tabs", "scripting", "alarms", "notifications"],
|
"permissions": ["storage", "contextMenus", "tabs", "scripting", "alarms", "notifications"],
|
||||||
"content_scripts": [
|
"content_scripts": [
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Reference in a new issue