@@ -0,0 +1,6 @@
+chrome.browserAction.onClicked.addListener(function (tab) {
+ // for the current tab, inject the "inject.js" file & execute it
+ // chrome.tabs.executeScript(tab.ib, {
+ // file: 'inject.js'
+ // });
+});
@@ -0,0 +1,7 @@
+(function() {
+ document.addEventListener("DOMContentLoaded", function () {
+ document.getElementById("nav").addEventListener("click", function () {
+ console.log(111);
+ });
+})();
@@ -0,0 +1,27 @@
+{
+ "name": "JSInject",
+ "description": "JSInject",
+ "version": "0.0.1",
+ "manifest_version": 2,
+ "permissions": [
+ "storage",
+ "activeTab"
+ ],
+ "background": {
+ "scripts": [
+ "background.js"
+ "persistent": true
+ },
+ "browser_action": {
+ "default_title": "Inject!"
+ "content_scripts": [{
+ "matches": [
+ "http://*/*",
+ "https://*/*"
+ "js": ["inject.js"],
+ "run_at": "document_start"
+ }]
+}
@@ -0,0 +1,24 @@
+'use strict';
+
+let registered = null;
+async function registerScript(message) {
+ const {
+ hosts,
+ code,
+ userScriptID,
+ } = message;
+ if (registered) {
+ await registered.unregister();
+ registered = null;
+ }
+ registered = await browser.userScripts.register({
+ matches: hosts,
+ js: [{code}],
+ scriptMetadata: {userScriptID},
+browser.runtime.onMessage.addListener(registerScript);
@@ -0,0 +1,5 @@
+document.addEventListener("DOMContentLoaded", function () {