Skip to content

Commit

Permalink
Make content script injection visible (#5001)
Browse files Browse the repository at this point in the history
  • Loading branch information
fregante committed Jan 12, 2023
1 parent 6aa2f85 commit 251b6d5
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/contentScript/contentScript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/

import "./contentScript.scss";
import "@/development/visualInjection";
import { uuidv4 } from "@/types/helpers";
import {
isInstalledInThisSession,
Expand Down
40 changes: 40 additions & 0 deletions src/development/visualInjection.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright (C) 2023 PixieBrix, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import { MAX_Z_INDEX } from "@/common";

if (process.env.ENVIRONMENT === "development") {
const indicator = document.createElement("div");

// Hide on hover
indicator.addEventListener("mouseenter", indicator.remove);

Object.assign(indicator.style, {
position: "fixed",
top: 0,
height: "1px",
zIndex: MAX_Z_INDEX,

// Vary position to see multiple injections
left: `${Math.random() * 100}px`,

// Add contrast so it's visible no matter the background
borderLeft: "solid 5px white",
borderRight: "solid 5px black",
});
document.body.prepend(indicator);
}

0 comments on commit 251b6d5

Please sign in to comment.