Skip to content

Commit

Permalink
#6548: Load PixieBrix into existing tabs on install (#6851)
Browse files Browse the repository at this point in the history
  • Loading branch information
fregante authored and Ben Loe committed Nov 28, 2023
1 parent 9f01c81 commit 7ec56b2
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 16 deletions.
18 changes: 17 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,9 @@
"uuid": "^9.0.1",
"webext-additional-permissions": "^2.4.0",
"webext-base-css": "^1.4.4",
"webext-content-scripts": "^2.5.5",
"webext-content-scripts": "^2.6.0",
"webext-detect-page": "^4.1.1",
"webext-inject-on-install": "^2.0.0-2",
"webext-messenger": "^0.25.0-0",
"webext-patterns": "^1.3.0",
"webext-polyfill-kinda": "^1.0.2",
Expand Down
2 changes: 2 additions & 0 deletions src/background/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

// extensionContext needs to be imported before webpack-target-webextension to
// ensure the webpack path is correct
// eslint-disable-next-line import/no-unassigned-import -- Automatic registration
import "webext-inject-on-install";
import "@/extensionContext";
import "@/development/autoreload";
import "@/development/errorsBadge";
Expand Down
2 changes: 1 addition & 1 deletion src/background/browserAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { ensureContentScript } from "@/background/contentScript";
import { rehydrateSidebar } from "@/contentScript/messenger/api";
import webextAlert from "./webextAlert";
import { browserAction, type Tab } from "@/mv3/api";
import { isScriptableUrl } from "@/permissions/permissionsUtils";
import { isScriptableUrl } from "webext-content-scripts";
import { memoizeUntilSettled } from "@/utils/promiseUtils";
import { getExtensionConsoleUrl } from "@/utils/extensionUtils";
import {
Expand Down
2 changes: 1 addition & 1 deletion src/background/initBrowserCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { toggleQuickBar } from "@/contentScript/messenger/api";
import { type Tab } from "@/mv3/api";
import { type Target } from "@/types/messengerTypes";
import { expectContext } from "@/utils/expectContext";
import { isScriptableUrl } from "@/permissions/permissionsUtils";
import { isScriptableUrl } from "webext-content-scripts";
import { ensureContentScript } from "./contentScript";

async function handleCommand(command: string, tab: Tab): Promise<void> {
Expand Down
3 changes: 2 additions & 1 deletion src/background/navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
import { reactivateTab, handleNavigate } from "@/contentScript/messenger/api";
import { forEachTab } from "@/utils/extensionUtils";
import { type Target } from "@/types/messengerTypes";
import { canAccessTab, isScriptableUrl } from "@/permissions/permissionsUtils";
import { canAccessTab } from "@/permissions/permissionsUtils";
import { isScriptableUrl } from "webext-content-scripts";
import { debounce } from "lodash";
import { syncFlagOn } from "@/store/syncFlags";
import { canAccessTab as canInjectTab, getTabUrl } from "webext-tools";
Expand Down
2 changes: 1 addition & 1 deletion src/pageEditor/EditorLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import RestrictedPane from "@/pageEditor/panes/RestrictedPane";
import InsertPane from "@/pageEditor/panes/insert/InsertPane";
import useCurrentUrl from "./hooks/useCurrentUrl";
import NonScriptablePage from "./NonScriptablePage";
import { isScriptableUrl } from "@/permissions/permissionsUtils";
import { isScriptableUrl } from "webext-content-scripts";
import Loader from "@/components/Loader";
import { selectIsStaleSession } from "@/store/sessionChanges/sessionChangesSelectors";
import StaleSessionPane from "@/pageEditor/panes/StaleSessionPane";
Expand Down
11 changes: 1 addition & 10 deletions src/permissions/permissionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
containsPermissions,
openPopupPrompt,
} from "@/background/messenger/api";
import { isScriptableUrl as _isScriptableUrl } from "webext-content-scripts";
import { isScriptableUrl } from "webext-content-scripts";
import { isUrlPermittedByManifest } from "webext-additional-permissions";
import {
getTabUrl,
Expand Down Expand Up @@ -177,15 +177,6 @@ async function requestPermissionsFromUserGesture(
return containsPermissions(permissions);
}

/**
* Determines whether a URL can potentially execute a content script.
* @since 1.7.36 this includes http urls
*
*/
export function isScriptableUrl(url?: string): boolean {
return url && _isScriptableUrl(url);
}

/**
* Determines whether PixieBrix can access the tab, depending on permissions and
* artificial protocol-based limitations
Expand Down

0 comments on commit 7ec56b2

Please sign in to comment.