Skip to content

Reduce to use content scripts #5

@azu

Description

@azu

Currently, we have used content scripts for "Console Integration"

"scripts/contentScript.js"

https://github.com/secretlint/webextension/blob/main/app/scripts/contentScript.ts

This approach always inject content scripts to any website.
Instead of it, we want to use chrome.scripting.executeScript, however it does not exists on Firefox.

tabs.executeScript() does not support arguments.
(Also we need to inject again when move pages.)

📝 Details of context.

tabs.executeScript({ code }) use dynamic eval, This is another reason why i avoid.
We need to treat it with caution and it will make complex.

tabs.executeScript() support file but it is not dynamic(no arguments).
tabs.executeScript() support code but it just use eval.

chrome.scripting.executeScript support freezed function and arguments, but Firefox does not support yet.

chrome.scripting.executeScript(
    {
      target: {tabId: tabId},
      func: changeBackgroundColor,
      args: [color],
    },
    () => { ... });

Related #4

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions