Skip to content

Commit 41e3a2a

Browse files
fix(plugin): plugin <script> tags accumulate in <head> when plugin is uninstalled
1 parent c77b117 commit 41e3a2a

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

src/lib/acode.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export default class Acode {
102102
list: themes.list,
103103
update: themes.update,
104104
// Deprecated, not supported anymore
105-
apply: () => {},
105+
apply: () => { },
106106
};
107107

108108
const sidebarAppsModule = {

src/lib/loadPlugin.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export default async function loadPlugin(pluginId, justInstalled = false) {
2222
}
2323

2424
return new Promise((resolve, reject) => {
25-
const $script = <script src={mainUrl}></script>;
25+
const $script = <script id={`${pluginId}-mainScript`} src={mainUrl}></script>;
2626

2727
$script.onerror = (error) => {
2828
reject(
@@ -43,7 +43,7 @@ export default async function loadPlugin(pluginId, justInstalled = false) {
4343
app.append($page);
4444
};
4545

46-
$page.onhide = function () {
46+
$page.onhide = function() {
4747
actionStack.remove(pluginId);
4848
};
4949

src/sidebarApps/extensions/index.js

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -688,18 +688,18 @@ function ListItem({ icon, name, id, version, downloads, installed, source }) {
688688
</span>
689689
{installed
690690
? <>
691-
{source
692-
? <span className="icon replay" data-action="rebuild-plugin" />
693-
: null}
694-
<span className="icon more_vert" data-action="more-plugin-action" />
695-
</>
691+
{source
692+
? <span className="icon replay" data-action="rebuild-plugin" />
693+
: null}
694+
<span className="icon more_vert" data-action="more-plugin-action" />
695+
</>
696696
: <button
697-
type="button"
698-
className="install-btn"
699-
data-action="install-plugin"
700-
>
701-
<span className="icon file_downloadget_app" />
702-
</button>}
697+
type="button"
698+
className="install-btn"
699+
data-action="install-plugin"
700+
>
701+
<span className="icon file_downloadget_app" />
702+
</button>}
703703
</div>
704704
);
705705

@@ -868,6 +868,8 @@ async function uninstall(id) {
868868
fsOperation(pluginDir).delete(),
869869
state.delete(state.storeUrl),
870870
]);
871+
const pluginMainScript = document.getElementById(`${id}-mainScript`)
872+
if (pluginMainScript) document.head.removeChild(pluginMainScript)
871873
acode.unmountPlugin(id);
872874

873875
const searchInput = container.querySelector('input[name="search-ext"]');

0 commit comments

Comments
 (0)