Skip to content

Commit

Permalink
Prevent duplicated link tags in Content script
Browse files Browse the repository at this point in the history
  • Loading branch information
nelsonr committed Oct 10, 2022
1 parent 6119100 commit 246ad1a
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/SuperCSSInject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ import { env } from "./utils";

function injectStylesheets(urlList: string[]) {
urlList.forEach((url) => {
const link = document.createElement("link");
link.rel = "stylesheet";
link.type = "text/css";
link.href = url;
link.classList.add("SuperCSSInject");

document.head.appendChild(link);
if (!document.querySelector(`link[href="${url}"]`)) {
const link = document.createElement("link");
link.rel = "stylesheet";
link.type = "text/css";
link.href = url;
link.classList.add("SuperCSSInject");

document.head.appendChild(link);
}
});
}

Expand Down

0 comments on commit 246ad1a

Please sign in to comment.