Skip to content

Inject findAndReplaceDOMText onto page via Chrome Extension? #80

@puyanwei

Description

@puyanwei

Hi,

Is there a way of adding this to a chrome extension? I want to highlight all same words which involves me adding a span to those found.

I have tried to add it in the manifest.json like this;

"content_scripts": [
        {
            "matches": ["<all_urls>"],
            "js": ["lib/findAndReplaceDOMText.js", "content.js"]
        }
    ],

as well as trying to append it via background.js (preload) or content.js (page) with something like this;

let script = document.createElement("script");
script.setAttribute("src", "lib/findAndReplaceDOMText.js");
(document.head || document.documentElement).appendChild(script);
script.remove();

However the console says;
findAndReplaceDOMText.js:7 Uncaught SyntaxError: Unexpected token <

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions