feat: chrome.action and chrome.notifications not exist in safari

This commit is contained in:
DIYgod
2024-02-03 23:17:48 +08:00
parent b761e6e14e
commit 5b4e96cfca
6 changed files with 2359 additions and 4975 deletions
+1
View File
@@ -0,0 +1 @@
pnpm-lock.yaml
+1 -1
View File
@@ -10,7 +10,7 @@
"dev:firefox": "plasmo dev --target=firefox-mv3 --no-cs-reload",
"build:firefox": "plasmo build --target=firefox-mv3",
"build:safari": "plasmo build --target=safari-mv3",
"safari-convert": "xcrun safari-web-extension-converter build/safari-mv3-prod --project-location build --bundle-identifier app.rsshub.RSSHub-Radar",
"safari-convert": "xcrun safari-web-extension-converter build/safari-mv3-prod --project-location build --bundle-identifier app.rsshub.RSSHub-Radar --force",
"safari-zip": "zip -r build/safari-mv3-prod.zip \"build/RSSHub Radar\"",
"build:safari:zip": "npm run build:safari && npm run safari-convert && npm run safari-zip",
"package": "plasmo package",
+2351 -4969
View File
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -1,10 +1,10 @@
import { getConfig } from "~/lib/config"
chrome.action.setBadgeBackgroundColor({
chrome.action?.setBadgeBackgroundColor?.({
color: "#F62800",
})
chrome.action.setBadgeTextColor({
chrome.action?.setBadgeTextColor?.({
color: "#fff",
})
+3 -3
View File
@@ -11,7 +11,7 @@ const storage = new Storage({
export const initUpdateNotifications = async () => {
const version = await storage.get("version")
if (!version || version !== info.version) {
chrome.notifications.create("RSSHubRadarUpdate", {
chrome.notifications?.create("RSSHubRadarUpdate", {
type: "basic",
iconUrl: RSSHubIcon,
title: version
@@ -19,12 +19,12 @@ export const initUpdateNotifications = async () => {
: chrome.i18n.getMessage("extensionInstallTip"),
message: `v${info.version}, ${chrome.i18n.getMessage("clickToViewChangeLog")}`,
})
chrome.notifications.onClicked.addListener((id) => {
chrome.notifications?.onClicked.addListener((id) => {
if (id === "RSSHubRadarUpdate") {
chrome.tabs.create({
url: "https://github.com/DIYgod/RSSHub-Radar/releases",
})
chrome.notifications.clear("RSSHubRadarUpdate")
chrome.notifications?.clear("RSSHubRadarUpdate")
}
})
await storage.set("version", info.version)
+1
View File
@@ -16,6 +16,7 @@ export function removeFunctionFields(obj) {
}
}
export function parseRSS(content: string) {
content = content.replaceAll("&lt;", "<").replaceAll("&gt;", ">")
if (content.includes("<rss ") || content.includes("<feed ")) {
const titleContent = content.match(/<title>(.*)<\/title>/)?.[1]
const title = titleContent