From 325ad4b08d581f9d27d6d8077adac17a4cb34f25 Mon Sep 17 00:00:00 2001
From: HanYaodong
Date: Mon, 5 Feb 2024 23:32:13 +0800
Subject: [PATCH] Remove deArrow related code
---
config.json.example | 12 ----------
public/help/index.html | 14 ------------
public/help/styles.css | 25 ---------------------
public/options/options.css | 24 --------------------
public/options/options.html | 33 +---------------------------
src/background.ts | 17 +-------------
src/help.ts | 29 +-----------------------
src/options.ts | 22 -------------------
src/utils/crossExtension.ts | 44 -------------------------------------
9 files changed, 3 insertions(+), 217 deletions(-)
delete mode 100644 src/utils/crossExtension.ts
diff --git a/config.json.example b/config.json.example
index 98c48187..1912aaee 100644
--- a/config.json.example
+++ b/config.json.example
@@ -28,17 +28,5 @@
"poi_highlight": "https://wiki.sponsor.ajay.app/w/Highlight",
"guidelines": "https://wiki.sponsor.ajay.app/w/Guidelines",
"mute": "https://wiki.sponsor.ajay.app/w/Mute_Segment"
- },
- "extensionImportList": {
- "chromium": [
- "enamippconapkdmgfgjchkhakpfinmaj"
- ],
- "firefox": [
- "deArrow@ajay.app",
- "deArrowBETA@ajay.app"
- ],
- "safari": [
- "app.ajay.dearrow.extension"
- ]
}
}
diff --git a/public/help/index.html b/public/help/index.html
index 4e14f186..91e268e9 100644
--- a/public/help/index.html
+++ b/public/help/index.html
@@ -63,20 +63,6 @@
>.
-
-
-
-
-
-
+
@@ -182,20 +165,6 @@
__MSG_whatShowCategoryWithoutPermission__
-
-
diff --git a/src/background.ts b/src/background.ts
index 161ee45a..727de34c 100644
--- a/src/background.ts
+++ b/src/background.ts
@@ -12,7 +12,6 @@ import { generateUserID } from "../maze-utils/src/setup";
window.SB = Config;
import Utils from "./utils";
-import { getExtensionIdsToImportFrom } from "./utils/crossExtension";
import { isFirefoxOrSafari } from "../maze-utils/src";
import { injectUpdatedScripts } from "../maze-utils/src/cleanup";
import { logWarn } from "./utils/logger";
@@ -88,20 +87,6 @@ chrome.runtime.onMessage.addListener(function (request, sender, callback) {
}
});
-chrome.runtime.onMessageExternal.addListener((request, sender, callback) => {
- if (getExtensionIdsToImportFrom().includes(sender.id)) {
- if (request.message === "requestConfig") {
- callback({
- userID: Config.config.userID,
- allowExpirements: Config.config.allowExpirements,
- showDonationLink: Config.config.showDonationLink,
- showUpsells: Config.config.showUpsells,
- darkMode: Config.config.darkMode,
- })
- }
- }
-});
-
chrome.runtime.onConnect.addListener((port) => {
if (port.name === "popup") {
chrome.tabs.query({
@@ -160,7 +145,7 @@ async function registerFirefoxContentScript(options: Registration) {
ids: [options.id]
}).catch(() => []);
- if (existingRegistrations.length > 0
+ if (existingRegistrations.length > 0
&& existingRegistrations[0].matches.every((match) => options.matches.includes(match))) {
// No need to register another script, already registered
return;
diff --git a/src/help.ts b/src/help.ts
index 67296473..455bca1d 100644
--- a/src/help.ts
+++ b/src/help.ts
@@ -3,7 +3,6 @@ import Config from "./config";
import { showDonationLink } from "./utils/configUtils";
import { waitFor } from "../maze-utils/src";
-import { isDeArrowInstalled } from "./utils/crossExtension";
if (document.readyState === "complete") {
init();
@@ -11,32 +10,6 @@ if (document.readyState === "complete") {
document.addEventListener("DOMContentLoaded", init);
}
-// DeArrow promotion
-waitFor(() => Config.isReady()).then(() => {
- if (Config.config.showNewFeaturePopups && Config.config.showUpsells) {
- isDeArrowInstalled().then((installed) => {
- if (!installed) {
- const deArrowPromotion = document.getElementById("dearrow-link");
- deArrowPromotion.classList.remove("hidden");
-
- deArrowPromotion.addEventListener("click", () => Config.config.showDeArrowPromotion = false);
-
- const text = deArrowPromotion.querySelector("#dearrow-link-text");
- text.textContent = `${chrome.i18n.getMessage("DeArrowPromotionMessage2").split("?")[0]}? ${chrome.i18n.getMessage("DeArrowPromotionMessage3")}`;
-
- const closeButton = deArrowPromotion.querySelector(".close-button");
- closeButton.addEventListener("click", (e) => {
- e.preventDefault();
-
- deArrowPromotion.classList.add("hidden");
- Config.config.showDeArrowPromotion = false;
- Config.config.showDeArrowInSettings = false;
- });
- }
- });
- }
-});
-
async function init() {
localizeHtmlPage();
@@ -49,4 +22,4 @@ async function init() {
if (!showDonationLink()) {
document.getElementById("sbDonate").style.display = "none";
}
-}
\ No newline at end of file
+}
diff --git a/src/options.ts b/src/options.ts
index 89315d38..8e595dfe 100644
--- a/src/options.ts
+++ b/src/options.ts
@@ -17,7 +17,6 @@ import { localizeHtmlPage } from "../maze-utils/src/setup";
import { StorageChangesObject } from "../maze-utils/src/config";
import { getHash } from "../maze-utils/src/hash";
import { isFirefoxOrSafari } from "../maze-utils/src";
-import { isDeArrowInstalled } from "./utils/crossExtension";
import { asyncRequestToServer } from "./utils/requests";
const utils = new Utils();
let embed = false;
@@ -78,27 +77,6 @@ async function init() {
donate.classList.add("hidden");
}
- // DeArrow promotion
- if (Config.config.showNewFeaturePopups && Config.config.showUpsells && Config.config.showDeArrowInSettings) {
- isDeArrowInstalled().then((installed) => {
- if (!installed) {
- const deArrowPromotion = document.getElementById("deArrowPromotion");
- deArrowPromotion.classList.remove("hidden");
-
- deArrowPromotion.addEventListener("click", () => Config.config.showDeArrowPromotion = false);
-
- const closeButton = deArrowPromotion.querySelector(".close-button");
- closeButton.addEventListener("click", (e) => {
- e.preventDefault();
-
- deArrowPromotion.classList.add("hidden");
- Config.config.showDeArrowPromotion = false;
- Config.config.showDeArrowInSettings = false;
- });
- }
- });
- }
-
const skipToHighlightKeybind = document.querySelector(`[data-sync="skipToHighlightKeybind"] .optionLabel`) as HTMLElement;
skipToHighlightKeybind.innerText = `${chrome.i18n.getMessage("skip_to_category").replace("{0}", chrome.i18n.getMessage("category_poi_highlight")).replace("?", "")}:`;
diff --git a/src/utils/crossExtension.ts b/src/utils/crossExtension.ts
deleted file mode 100644
index 183ae931..00000000
--- a/src/utils/crossExtension.ts
+++ /dev/null
@@ -1,44 +0,0 @@
-import * as CompileConfig from "../../config.json";
-
-import Config from "../config";
-import { isSafari } from "../../maze-utils/src/config";
-import { isFirefoxOrSafari } from "../../maze-utils/src";
-
-export function isDeArrowInstalled(): Promise {
- if (Config.config.deArrowInstalled) {
- return Promise.resolve(true);
- } else {
- return new Promise((resolve) => {
- const extensionIds = getExtensionIdsToImportFrom();
-
- let count = 0;
- for (const id of extensionIds) {
- chrome.runtime.sendMessage(id, { message: "isInstalled" }, (response) => {
- if (chrome.runtime.lastError) {
- count++;
-
- if (count === extensionIds.length) {
- resolve(false);
- }
- return;
- }
-
- resolve(response);
- if (response) {
- Config.config.deArrowInstalled = true;
- }
- });
- }
- });
- }
-}
-
-export function getExtensionIdsToImportFrom(): string[] {
- if (isSafari()) {
- return CompileConfig.extensionImportList.safari;
- } else if (isFirefoxOrSafari()) {
- return CompileConfig.extensionImportList.firefox;
- } else {
- return CompileConfig.extensionImportList.chromium;
- }
-}
\ No newline at end of file