{"id":22357731,"url":"https://github.com/bluzi/chrome-extension-execute-on-website","last_synced_at":"2025-07-30T10:33:23.603Z","repository":{"id":25930638,"uuid":"105200345","full_name":"bluzi/chrome-extension-execute-on-website","owner":"bluzi","description":"Access JS on web pages directly through your Chrome extensions","archived":false,"fork":false,"pushed_at":"2018-11-16T13:17:57.000Z","size":9,"stargazers_count":9,"open_issues_count":9,"forks_count":11,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-29T23:26:57.653Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/chrome-extension-execute-on-website","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/bluzi.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}},"created_at":"2017-09-28T21:19:36.000Z","updated_at":"2024-04-18T11:19:12.000Z","dependencies_parsed_at":"2022-07-24T23:46:16.007Z","dependency_job_id":null,"html_url":"https://github.com/bluzi/chrome-extension-execute-on-website","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/bluzi%2Fchrome-extension-execute-on-website","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bluzi%2Fchrome-extension-execute-on-website/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bluzi%2Fchrome-extension-execute-on-website/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bluzi%2Fchrome-extension-execute-on-website/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bluzi","download_url":"https://codeload.github.com/bluzi/chrome-extension-execute-on-website/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228124558,"owners_count":17873170,"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-12-04T14:16:04.205Z","updated_at":"2024-12-04T14:16:04.994Z","avatar_url":"https://github.com/bluzi.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# chrome-extension-execute-on-website\n\nIt is a long name, but it will self-explanatory so, its worth\n\nOr is it?...\n\n## What is it?\n\nIt turns out that Chrome extensions does not have access to the JavaScript on a webpage, even if the extension is a content script. As a result, you can't access variables and content on the page itself.\n\nIt's disapointing. Anyway, there is a solution, you have to inject a script tag to the page and then execute whatever you want in this script. You may ask yourself what is the problem? It's ugly as f, that's the problem.\n\nWell, luckily, I've got the solution!\n\nThis tiny library allows you to easily execute JavaScript code in a webpage from your Chrome extension.\n\n## Usage\nBut how does it work? It is as simple as this:\n\n```javascript\nexec(() =\u003e {\n    console.log('This is the window of the current webpage:', window);\n});\n```\n\nNice, huh? I know!\n\nAnyway, so that's more or less it. Best 500 bytes (unminified) your Chrome extension is going to get.\n\n## Installation\n\n### jsDelivr (Recommended)\nI just love jsDelivr. \n\n\n1. Download the script from the this --\u003e [URL](https://cdn.jsdelivr.net/npm/chrome-extension-execute-on-website/execute-on-website.min.js) \u003c--, and put it somewhere in your extension's folder:\n\n\n2. Go to your manifest file, make sure you have `contentSettings` permission, like this:\n```json\n  \"permissions\": [\n    \"contentSettings\"\n  ]\n```\n\nUnder `content_scripts` add a `js` array and insert the path to the library file as an item.\n\nNo worries, here's an example:\n\nAssuming your script is in a folder called `js`:\n\n```json\n\"content_scripts\": [\n    {\n      \"js\": [\n        \"js/execute-on-website.min.js\",\n        \"./inject.js\"\n      ]\n    }\n  ]\n```\n\nIt's as simple as that.\n\n### npm\n\nNavigate to your extension's folder, and run the following command: (After making sure you have Node installed)\n```bash\nnpm i chrome-extension-execute-on-website\n```\nGood, now go to your `manifest.json`, make sure you have `contentSettings` permission:\n```json\n  \"permissions\": [\n    \"contentSettings\"\n  ]\n```\nUnder `content_scripts` add `js` array and add the following path as an item:\n\n`node_modules/chrome-extension-execute-on-website/execute-on-website.js`\n\nAnd that should do the job. Here is an example:\n\n```json\n\"content_scripts\": [\n    {\n      \"js\": [\n        \"node_modules/chrome-extension-execute-on-website/execute-on-website.js\",\n        \"./inject.js\"\n      ]\n    }\n  ]\n```\n\n## Sample Manifest\nHere is an example of a full manifest, with the library included:\n```json\n{\n  \"name\": \"My Extension\",\n  \"version\": \"0.0.4\",\n  \"manifest_version\": 2,\n  \"description\": \"\",\n  \"homepage_url\": \"http://eliran.net\",\n  \"icons\": {\n    \"16\": \"icons/Lightning16.png\",\n    \"19\": \"icons/Lightning19.png\",\n    \"48\": \"icons/Lightning48.png\",\n    \"128\": \"icons/Lightning128.png\"\n  },\n  \"permissions\": [\n    \"contentSettings\"\n  ],\n  \"content_scripts\": [\n    {\n      \"matches\": [\n        \"*://*/*\"\n      ],\n      \"js\": [\n        \"js/execute-on-website.min.js\",\n        \"./inject.js\"\n      ]\n    }\n  ]\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbluzi%2Fchrome-extension-execute-on-website","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbluzi%2Fchrome-extension-execute-on-website","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbluzi%2Fchrome-extension-execute-on-website/lists"}