GitBucket
4.23.0
Toggle navigation
Sign in
Files
Branches
2
Releases
Issues
Pull requests
Labels
Priorities
Milestones
Wiki
Forks
sample-chrome-extension
/
sample1
Browse code
バックグラウンドありverを追加
sample2
1 parent
5898ac7
commit
34756d04bb0f90b4bec82dfdc5e74bb2db02dbc8
yhornisse
authored
on 26 Dec 2019
Patch
Showing
3 changed files
bg.js
main.js
manifest.json
Ignore Space
Show notes
View
bg.js
0 → 100644
chrome.runtime.onConnect.addListener(function(port){ port.onMessage.addListener(function(request) { console.log('バックグラウンドアンドページに出力'); chrome.tabs.create({url:request.url}) }); });
Ignore Space
Show notes
View
main.js
window.addEventListener('keydown', function(evt){ let port = chrome.extension.connect(); switch ( evt.keyCode ){ case 65: // 'a' port.postMessage({'url':'https://www.google.co.jp'}); break; } });
window.alert('Hello, World');
Ignore Space
Show notes
View
manifest.json
{ "name": "sample extension", "description": "sample code", "manifest_version": 2, "background": { "scripts": [ "bg.js" ], "persistent": false }, "content_scripts": [ { "matches": [ "http://*/*", "https://*/*" ], "js": [ "main.js" ] } ], "permissions": [ "http://*/*", "https://*/*", "tabs" ], "version": "1.0.0.0" }
{ "name": "sample extension", "description": "sample code", "manifest_version": 2, "content_scripts": [ { "matches": [ "http://*/*", "https://*/*" ], "js": [ "main.js" ] } ], "version": "1.0.0.0" }
Show line notes below