Code Monkey home page Code Monkey logo

manifest-v3-beastify's Introduction

Manifest V3 Beastify

MV3 version of the classic WebExtension example "Beastify".

What it does

The extension includes:

  • a browser action with a popup including HTML, CSS, and JS
  • a content script
  • three images, each of a different beast, packaged as web accessible resources
  • a manifest which:
    • uses the new MV3 syntax as indicated for the key web_accessible_resources.
    • has replaced the 'browser_action' key for action.
    • includes permission for the scripting WebExtension API which was previously not used.

When the user clicks the browser action button, the popup is shown, enabling the user to choose one of three beasts.

When it is shown, the popup injects a content script into the current page.

When the user chooses a beast, the extension sends the content script a message containing the name of the chosen beast.

When the content script receives this message, it replaces the current page content with an image of the chosen beast.

When the user clicks the reset button, the page reloads, and reverts to its original form.

Note that:

  • if the user reloads the tab, or switches tabs, while the popup is open, then the popup won't be able to beastify the page any more (because the content script was injected into the original tab).

  • by default scripting.executeScript() injects the script only when the web page and its resources have finished loading. This means that clicks in the popup will have no effect until the page has finished loading. Immediate execution requires to set the optional parameter ´injectImmediately´ to true.

  • it's not possible to inject content scripts into certain pages, including privileged browser pages like "about:debugging" and the addons.mozilla.org website from a Mozilla browser. If the user clicks the beastify icon when such a page is loaded into the active tab, the popup displays an error message.

What it shows

  • write a browser action with a popup
  • how to have different browser_action images based upon the theme
  • give the popup style and behavior using CSS and JS
  • inject a content script programmatically using scripting.executeScript()
  • send a message from the main extension to a content script
  • use web accessible resources to enable web pages to load packaged content

manifest-v3-beastify's People

Contributors

osvaldobarrera avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.