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.
2022-08-15 13:51:43 +00:00
|
|
|
import browser from "@lumeweb/webextension-polyfill";
|
|
|
|
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(
|
|
|
|
new URL(details.pageUrl as string).hostname
|
|
|
|
);
|
|
|
|
browser.menus.update("clear-cache", {
|
|
|
|
visible: provider instanceof IpfsProvider,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|