From 238244d7a9acee3d9149aa06d6ce78049b83c742 Mon Sep 17 00:00:00 2001 From: Toru Kobayashi Date: Wed, 13 Jul 2022 11:01:10 +0900 Subject: [PATCH] Revert "fix: a hydration error in SSR apps (#76)" (#78) This reverts commit c30626f44ec2eab1dabe81ee101aef4fbf19c2d2. --- .../swr-devtools-extensions/manifest-v2.json | 6 ------ .../swr-devtools-extensions/manifest.json | 20 +++++++++++-------- .../swr-devtools-extensions/src/content.ts | 8 ++++++++ .../swr-devtools-extensions/src/devtools.ts | 13 +----------- 4 files changed, 21 insertions(+), 26 deletions(-) diff --git a/packages/swr-devtools-extensions/manifest-v2.json b/packages/swr-devtools-extensions/manifest-v2.json index a9fbbfb..cb8fd57 100644 --- a/packages/swr-devtools-extensions/manifest-v2.json +++ b/packages/swr-devtools-extensions/manifest-v2.json @@ -15,12 +15,6 @@ "background.js" ] }, - "permissions": [ - "scripting", - "tabs", - "http://*/", - "https://*/" - ], "content_scripts": [ { "matches": [ diff --git a/packages/swr-devtools-extensions/manifest.json b/packages/swr-devtools-extensions/manifest.json index 33e3f8b..eb8baa0 100644 --- a/packages/swr-devtools-extensions/manifest.json +++ b/packages/swr-devtools-extensions/manifest.json @@ -13,14 +13,6 @@ "background": { "service_worker": "background.js" }, - "permissions": [ - "scripting", - "tabs" - ], - "host_permissions": [ - "http://*/", - "https://*/" - ], "content_scripts": [ { "matches": [ @@ -32,5 +24,17 @@ ], "run_at": "document_start" } + ], + "web_accessible_resources": [ + { + "resources": [ + "web-accessible.js" + ], + "matches": [ + "https://*/*", + "http://*/*" + + ] + } ] } diff --git a/packages/swr-devtools-extensions/src/content.ts b/packages/swr-devtools-extensions/src/content.ts index aa09570..f69bbf6 100644 --- a/packages/swr-devtools-extensions/src/content.ts +++ b/packages/swr-devtools-extensions/src/content.ts @@ -1,6 +1,14 @@ import { DevToolsMessage } from "swr-devtools"; import { Runtime, runtime } from "webextension-polyfill"; +const injectDevToolsHook = () => { + const script = document.createElement("script"); + script.setAttribute("type", "text/javascript"); + script.setAttribute("src", chrome.runtime.getURL("web-accessible.js")); + document.documentElement.appendChild(script); +}; +injectDevToolsHook(); + export type ContentMessage = | { type: "load"; diff --git a/packages/swr-devtools-extensions/src/devtools.ts b/packages/swr-devtools-extensions/src/devtools.ts index 907c856..f9e77c7 100644 --- a/packages/swr-devtools-extensions/src/devtools.ts +++ b/packages/swr-devtools-extensions/src/devtools.ts @@ -1,16 +1,5 @@ -import { devtools, scripting } from "webextension-polyfill"; +import { devtools } from "webextension-polyfill"; devtools.panels.create("SWR", "", "panel.html").then(() => { console.log("The DevTools panel has been created"); }); - -scripting - .executeScript({ - target: { - tabId: devtools.inspectedWindow.tabId, - allFrames: true, - }, - files: ["web-accessible.js"], - }) - .then((r) => console.log("executeScript has been success", r)) - .catch((e) => console.log("executeScript has been failed", e));