Git Product home page Git Product logo

extension's Introduction

Chrome Extensions

Referred Video: https://youtu.be/GGi7Brsf7js?si=t9keVe8_psMfw-3v

Basic Concepts

img.png

Service Worker Context

Service works run in background and are not visible to the user. It is same for web page as well

img_2.png

Below is the configuration we need to have for service worker in manifest.json img_3.png

  • Here action key is for chrome.action we used
  • Since we want to run service worker in background we mention its path in background key
  • For running script, we need scripting permission
  • host_persmission help us define where can allow running our script. Here we're enabled to run everywhere

Popup Context

img_4.png

img_5.png

img_6.png

  • Here inside action we declare our popup page
  • Here in index.js document.getElementById('myButton') refer to index.html DOM

Content Script Context

img_7.png

  • Here in same index.js highlighted document.body refer to the page where it is currently running

img_8.png Here it will be body of this example.com page

File used for simple extension img_9.png

Using Vite

Step-1

Start with normal Vite app creation through

npm create vite@latest

Step-2

Place manifest.json file in public folder so that after build it is placed at the root of dist folder

img_10.png

Step-3

npm run build

After this load the generated dist folder to the browser

That's it, now we can access our extension.

How to load UI on extension pop-up

img_11.png

img_12.png

How to access current tab info and show alert

npm i -D @types/chrome

img_13.png img_14.png

How to change background color of the page where extension is running

img_15.png

How to change the background color of the tab through popup

img_16.png

img_18.png โŒ This will not work as the highlighted function is running in context where the tab is currently on. Whereas colour variable is running in context of pop-up.

img_19.png โœ… This will work, as we are passing it through args: [colour]

img_20.png

extension's People

Contributors

anjaysahoo 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.