browser-extension-settings 0.2.9 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/common.ts +1 -1
- package/lib/extension-list.ts +37 -6
- package/lib/settings.ts +4 -1
- package/package.json +1 -1
package/lib/common.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const besVersion =
|
|
1
|
+
export const besVersion = 30
|
|
2
2
|
export const openButton = `<svg viewBox="0 0 60.2601318359375 84.8134765625" version="1.1" xmlns="http://www.w3.org/2000/svg" class=" glyph-box" style="height: 9.62969px; width: 6.84191px;"><g transform="matrix(1 0 0 1 -6.194965820312518 77.63671875)"><path d="M66.4551-35.2539C66.4551-36.4746 65.9668-37.5977 65.0391-38.4766L26.3672-76.3672C25.4883-77.1973 24.4141-77.6367 23.1445-77.6367C20.6543-77.6367 18.7012-75.7324 18.7012-73.1934C18.7012-71.9727 19.1895-70.8496 19.9707-70.0195L55.5176-35.2539L19.9707-0.488281C19.1895 0.341797 18.7012 1.41602 18.7012 2.68555C18.7012 5.22461 20.6543 7.12891 23.1445 7.12891C24.4141 7.12891 25.4883 6.68945 26.3672 5.81055L65.0391-32.0312C65.9668-32.959 66.4551-34.0332 66.4551-35.2539Z"></path></g></svg>`
|
|
3
3
|
export const openInNewTabButton = `<svg viewBox="0 0 72.127685546875 72.2177734375" version="1.1" xmlns="http://www.w3.org/2000/svg" class=" glyph-box" style="height: 8.19958px; width: 8.18935px;"><g transform="matrix(1 0 0 1 -12.451127929687573 71.3388671875)"><path d="M84.5703-17.334L84.5215-66.4551C84.5215-69.2383 82.7148-71.1914 79.7852-71.1914L30.6641-71.1914C27.9297-71.1914 26.0742-69.0918 26.0742-66.748C26.0742-64.4043 28.1738-62.4023 30.4688-62.4023L47.4609-62.4023L71.2891-63.1836L62.207-55.2246L13.8184-6.73828C12.9395-5.85938 12.4512-4.73633 12.4512-3.66211C12.4512-1.31836 14.5508 0.878906 16.9922 0.878906C18.1152 0.878906 19.1895 0.488281 20.0684-0.439453L68.5547-48.877L76.6113-58.0078L75.7324-35.2051L75.7324-17.1387C75.7324-14.8438 77.7344-12.6953 80.127-12.6953C82.4707-12.6953 84.5703-14.6973 84.5703-17.334Z"></path></g></svg>`
|
|
4
4
|
export const settingButton = `<svg viewBox="0 0 16 16" version="1.1">
|
package/lib/extension-list.ts
CHANGED
|
@@ -27,23 +27,33 @@ const relatedExtensions: RelatedExtension[] = [
|
|
|
27
27
|
{
|
|
28
28
|
id: "utags",
|
|
29
29
|
title: "🏷️ UTags - Add usertags to links",
|
|
30
|
-
url: "https://greasyfork.org/scripts/460718",
|
|
30
|
+
url: "https://greasyfork.org/zh-CN/scripts/460718-utags-add-usertags-to-links",
|
|
31
31
|
},
|
|
32
32
|
{
|
|
33
33
|
id: "links-helper",
|
|
34
34
|
title: "🔗 链接助手",
|
|
35
35
|
description: "在新标签页中打开第三方网站链接,图片链接转图片标签等",
|
|
36
|
-
url: "https://greasyfork.org/scripts/464541",
|
|
36
|
+
url: "https://greasyfork.org/zh-CN/scripts/464541-links-helper",
|
|
37
37
|
},
|
|
38
38
|
{
|
|
39
39
|
id: "v2ex.rep",
|
|
40
40
|
title: "V2EX.REP - 专注提升 V2EX 主题回复浏览体验",
|
|
41
|
-
url: "https://greasyfork.org/scripts/466589",
|
|
41
|
+
url: "https://greasyfork.org/zh-CN/scripts/466589-v2ex-rep-%E4%B8%93%E6%B3%A8%E6%8F%90%E5%8D%87-v2ex-%E4%B8%BB%E9%A2%98%E5%9B%9E%E5%A4%8D%E6%B5%8F%E8%A7%88%E4%BD%93%E9%AA%8C",
|
|
42
42
|
},
|
|
43
43
|
{
|
|
44
44
|
id: "v2ex.min",
|
|
45
45
|
title: "v2ex.min - V2EX 极简风格",
|
|
46
|
-
url: "https://greasyfork.org/scripts/463552",
|
|
46
|
+
url: "https://greasyfork.org/zh-CN/scripts/463552-v2ex-min-v2ex-%E6%9E%81%E7%AE%80%E9%A3%8E%E6%A0%BC",
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
id: "replace-ugly-avatars",
|
|
50
|
+
title: "赐你个头像吧",
|
|
51
|
+
url: "https://greasyfork.org/zh-CN/scripts/472616-replace-ugly-avatars",
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
id: "more-by-pipecraft",
|
|
55
|
+
title: "更多有趣的脚本",
|
|
56
|
+
url: "https://greasyfork.org/zh-CN/users/1030884-pipecraft",
|
|
47
57
|
},
|
|
48
58
|
]
|
|
49
59
|
|
|
@@ -132,17 +142,38 @@ const createInstalledExtension = (installedExtension: InstalledExtension) => {
|
|
|
132
142
|
}
|
|
133
143
|
|
|
134
144
|
const updateRelatedExtensions = (container: HTMLElement) => {
|
|
135
|
-
|
|
145
|
+
const relatedExtensionElements = $$("[data-extension-id]", container)
|
|
146
|
+
if (relatedExtensionElements.length > 0) {
|
|
147
|
+
for (const relatedExtensionElement of relatedExtensionElements) {
|
|
148
|
+
if (
|
|
149
|
+
isInstalledExtension(
|
|
150
|
+
relatedExtensionElement.dataset.extensionId || "noid"
|
|
151
|
+
)
|
|
152
|
+
) {
|
|
153
|
+
relatedExtensionElement.remove()
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
} else {
|
|
157
|
+
container.innerHTML = createHTML("")
|
|
158
|
+
}
|
|
136
159
|
|
|
137
160
|
for (const relatedExtension of relatedExtensions) {
|
|
138
161
|
// console.log(relatedExtension)
|
|
139
162
|
|
|
140
|
-
if (
|
|
163
|
+
if (
|
|
164
|
+
isInstalledExtension(relatedExtension.id) ||
|
|
165
|
+
$(`[data-extension-id="${relatedExtension.id}"]`, container)
|
|
166
|
+
) {
|
|
141
167
|
continue
|
|
142
168
|
}
|
|
143
169
|
|
|
170
|
+
if ($$("[data-extension-id]", container).length >= 4) {
|
|
171
|
+
return
|
|
172
|
+
}
|
|
173
|
+
|
|
144
174
|
const div4 = addElement(container, "div", {
|
|
145
175
|
class: "related_extension",
|
|
176
|
+
"data-extension-id": relatedExtension.id,
|
|
146
177
|
})
|
|
147
178
|
|
|
148
179
|
const a = addElement(div4, "a", {
|
package/lib/settings.ts
CHANGED
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
parseInt10,
|
|
15
15
|
removeEventListener,
|
|
16
16
|
runWhenBodyExists,
|
|
17
|
+
runWhenHeadExists,
|
|
17
18
|
} from "browser-extension-utils"
|
|
18
19
|
import styleText from "data-text:./style.scss"
|
|
19
20
|
import { createSwitchOption } from "./switch"
|
|
@@ -514,7 +515,9 @@ export const initSettings = async (options: SettingsOptions) => {
|
|
|
514
515
|
})
|
|
515
516
|
|
|
516
517
|
settings = await getSettings()
|
|
517
|
-
|
|
518
|
+
runWhenHeadExists(() => {
|
|
519
|
+
addStyle(getSettingsStyle())
|
|
520
|
+
})
|
|
518
521
|
runWhenBodyExists(() => {
|
|
519
522
|
initExtensionList()
|
|
520
523
|
addSideMenu()
|