{"id":18410743,"url":"https://github.com/jk-oster/example-chrome-extension","last_synced_at":"2025-04-12T22:47:18.946Z","repository":{"id":120556127,"uuid":"556830569","full_name":"jk-oster/example-chrome-extension","owner":"jk-oster","description":null,"archived":false,"fork":false,"pushed_at":"2022-10-26T15:57:22.000Z","size":114,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"staging","last_synced_at":"2024-12-24T15:19:04.440Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jk-oster.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-10-24T15:40:02.000Z","updated_at":"2022-10-26T15:57:53.000Z","dependencies_parsed_at":null,"dependency_job_id":"1fea05f7-e164-43a4-bf80-ce5f11d23e2c","html_url":"https://github.com/jk-oster/example-chrome-extension","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jk-oster%2Fexample-chrome-extension","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jk-oster%2Fexample-chrome-extension/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jk-oster%2Fexample-chrome-extension/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jk-oster%2Fexample-chrome-extension/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jk-oster","download_url":"https://codeload.github.com/jk-oster/example-chrome-extension/tar.gz/refs/heads/staging","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239092738,"owners_count":19580214,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T03:33:41.431Z","updated_at":"2025-02-16T05:28:40.638Z","avatar_url":"https://github.com/jk-oster.png","language":"JavaScript","readme":"# Chrome Extension\nhttps://developer.chrome.com/docs/extensions/\nhttps://developer.chrome.com/docs/extensions/reference/\n\n\nChrome extensions have full access to the Browser-(`chrome`)-API and therefore can change the behaviour and look and feel of the browser.\n\n## Developer tools\n- Active 'Developer Mode' in Chrome Extensions Manager\n- The popup.js and background.js can be debuged through the link to the developer tools in the extension manager page of chrome\n- Chrome Extension Developer Tools for VS-Code: aaravb.chrome-extension-developer-tools\n- Chrome Extension Manifest JSON Schema fpr VS-Code: cezaraugusto.vscode-chrome-extesion-manifest-json-schema\n- Chrome Extension for hot reloading: https://chrome.google.com/webstore/detail/extensions-reloader/fimgfedafeadlieiabdeeaodndnlbhid/related?hl=de\n\n## The extension `manifest.json`\n```json\n{\n  \"name\": \"Example Chrome Extension\",\n  \"version\": \"0.0.3\",\n  \"manifest_version\": 3,\n  \"content_scripts\": [\n    {\n      \"matches\" : [\n          \"https://www.google.com/search*\",\n          \"https://duckduckgo.com/*\"\n      ],\n      \"js\" :  [\"content.js\"]\n    }\n  ],\n  \"background\": {\n      \"service_worker\": \"background.js\"\n  },\n  \"action\": {\n      \"default_icon\": {              \n        \"32\": \"obsidian32.png\",    \n        \"48\": \"obsidian48.png\"\n      },\n      \"default_title\": \"Example - Click Me\",  \n      \"default_popup\": \"popup.html\" \n    },\n  \"permissions\": [\"activeTab\", \"scripting\", \"tabs\", \"storage\"]\n}\n```\n- Defines the capabilities, permissions and entrypoints of the extension\n- ``\"matches\"`` option defines on which pages the content scripts should be loaded\n    - to load on all pages use `\"\u003call_urls\u003e\"`\n    - can use wildcards `*`\n\n## The `background.js`\n- Runs when the chrome browser is launched.\n- Runs as service worker in the background.\n- Can be debugged through the link in the chrome extension settings.\n- Can not access the DOM.\n- Can communicate to tabs through the `chrome.tabs.sendMessage(...)` API.\n- Can e.q. handle storing extension settings in the background.\n- IMPORTANT: `chrome.action.onClick`  will not fire if a ``\"default_popup\"`` is defined in ``manifest.json``!\n\n### The `install.html`\n- Is optionally loaded after successful installation of the background service worker because manually defined so in the `background.js`\n\n## The `popup.html`\n- Is loaded into the opoup window below the Extension Icon every time the extension action button is clicked\n- Maximum size of 800x600\n\n### The `popup.js`\n- Is loaded through the `popup.html` inside it's \"own window\"\n- Can not access the current page DOM but only the `popup.html` DOM\n- Can communicate to tabs through the `chrome.tabs.sendMessage(...)` API\n\n## The `content.js`\n- Is run on any new page load if the current URL matches on of the listed `matches` of the `manifest.json`\n- Can access the DOM of the current browser window.\n- Can receive messages from ``background`.js`` or ``popup.js`` through the `chrome.runtime.onMessage` API\n\n## The `options.html`\n- Is loaded on *extension action icon right click -\u003e options*\n- Can e.q. be used for visually managing extension settings\n\n### The `options.js`\n- Is loaded through the `options.hml`\n- Can e.q. store extension settings through the `chrome.storage.sync` API\n\n## The `injectContent.js`\n- Is injected into the current tab by the `chrome.scripting.executeScript(...)` API \n\n## Useful links resources\nhttps://developer.chrome.com/docs/extensions/reference/storage/\nhttps://developer.chrome.com/docs/extensions/mv3/options/\n\n## Credit\nThanks for the icons @[elias ruiz](https://eliasruiz.com/) on https://icon-icons.com/icon/Obsidian-Alt-macOS-BigSur/189887","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjk-oster%2Fexample-chrome-extension","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjk-oster%2Fexample-chrome-extension","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjk-oster%2Fexample-chrome-extension/lists"}