Last active
June 4, 2021 11:04
-
-
Save akirattii/b2070e184035aef98db832bedf7f747e to your computer and use it in GitHub Desktop.
an example of chrome extension, which can be opened as new tab by click its browser icon.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log("background"); | |
chrome.browserAction.onClicked.addListener(function(tab) { | |
chrome.tabs.create({ | |
'url': chrome.extension.getURL('popup.html') | |
}, function(tab) { | |
// Tab opened. | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log("content script"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "example-app", | |
"version": "0.1.0", | |
"manifest_version": 2, | |
"description": "a example extension for Chrome", | |
"author": "Taro TANAKA <[email protected]> (http://www.example.com)", | |
"permissions": [ | |
"<all_urls>", | |
"storage", | |
"unlimitedStorage", | |
"tabs", | |
"activeTab", | |
"http://*/*", | |
"https://*/*" | |
], | |
"icons": { | |
"128": "./icon.png" | |
}, | |
"web_accessible_resources": [ | |
"./icon.png" | |
], | |
"content_scripts": [{ | |
"all_frames": true, | |
"matches": ["<all_urls>"], | |
"js": ["./content.js"], | |
"css": [] | |
}], | |
"background": { | |
"scripts": ["./background.js"], | |
"persistent": false | |
}, | |
"browser_action": { | |
"default_icon": "./icon.png" | |
}, | |
"update_url": "https://clients2.google.com/service/update2/crx" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>example-app</title> | |
<script src="extlib/js/jquery-3.3.1.min.js"></script> | |
<link rel="stylesheet" href="extlib/css/bootstrap.min.css"> | |
<script src="extlib/js/bootstrap.min.js"></script> | |
</head> | |
<body class="container mx-auto pb-4"> | |
<div>Hello chrome extension!<div> | |
<script src="popup.js"></script> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log("popup script"); | |
if ($) { | |
console.log("jquery available!"); | |
} | |
// here can use jQuery... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment