This repository has been archived on 2023-12-17. You can view files and clone it, but cannot push or open issues or pull requests.
2023-07-17 15:39:16 +00:00
|
|
|
import browser from "webextension-polyfill";
|
2022-08-15 13:51:43 +00:00
|
|
|
import type WebEngine from "./webEngine.js";
|
|
|
|
import type { Menus, Tabs } from "./types.js";
|
|
|
|
import IpfsProvider from "./contentProviders/ipfsProvider.js";
|
|
|
|
|
|
|
|
export default function setup(engine: WebEngine) {
|
|
|
|
browser.menus.create({
|
|
|
|
title: "Clear Cache",
|
|
|
|
id: "clear-cache",
|
|
|
|
onclick: async (info: Menus.OnClickData, tab: Tabs.Tab) => {
|
|
|
|
browser.tabs.reload(tab.id);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
browser.menus.onShown.addListener((details: Menus.OnShownInfoType) => {
|
2022-08-22 07:57:15 +00:00
|
|
|
if (!details.pageUrl) {
|
|
|
|
return;
|
|
|
|
}
|
2022-08-15 13:51:43 +00:00
|
|
|
const provider = engine.getDomainContentProvider(
|
2023-07-17 15:39:16 +00:00
|
|
|
new URL(details.pageUrl as string).hostname,
|
2022-08-15 13:51:43 +00:00
|
|
|
);
|
|
|
|
browser.menus.update("clear-cache", {
|
|
|
|
visible: provider instanceof IpfsProvider,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|