Skip to content

Properly reset the tab content in Chrome #4

@rubenvar

Description

@rubenvar

In Firefox, the following code works:

browser.tabs.insertCSS({ file: '/popup/css/insert.css' });

// ...after, when Reset is clicked:
browser.tabs.removeCSS({ file: '/popup/css/insert.css' });

However, Chrome doesn't support .removeCSS() until version 87 (at the time of writing, still in beta).

So in Chrome I can't just remove the previously inserted CSS as I do in Firefox 🤷‍♂️.

Probable solution

To change the way the css is inserted: Instead of using the browser.tabs API, insert it in the html as a node.

That way it's possible to remove it later.

But this feels too complicated for what it is, plus the .removeCSS() already works on Firefox.

Current solution

So for now, the solution is to just reload the tab 🤷‍♂️.

- browser.tabs.removeCSS({ file: '/popup/css/insert.css' });
+ browser.tabs.reload();

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