diff --git a/mpMath/assets/js/content-script.js b/mpMath/assets/js/content-script.js index 63fc2d0..b673d67 100644 --- a/mpMath/assets/js/content-script.js +++ b/mpMath/assets/js/content-script.js @@ -29,7 +29,7 @@ setTimeout(function () { }, 1000); // 等待文档加载完毕 -chrome.extension.sendMessage({}, function (response) { +chrome.runtime.sendMessage({}, function (response) { var readyStateCheckInterval = setInterval(function () { if (document.readyState === 'complete') { clearInterval(readyStateCheckInterval); @@ -37,13 +37,14 @@ chrome.extension.sendMessage({}, function (response) { if ($('#js_media_list')[0]) { // 公式编辑弹窗 let iframe = document.createElement('iframe'); - iframe.src = chrome.extension.getURL('./pages/popup.html'); + iframe.src = chrome.runtime.getURL('./pages/popup.html'); iframe.setAttribute('class', 'mpm-modal'); iframe.frameBorder = 0; iframe.allowTransparency = true; iframe.id = 'popup'; iframe.style.display = 'none'; document.body.appendChild(iframe); + console.log(iframe) // 上方菜单栏公式按钮 let formulaMenu = document.createElement('li'); diff --git a/mpMath/manifest.json b/mpMath/manifest.json index 8e82ca9..8dfc4d3 100644 --- a/mpMath/manifest.json +++ b/mpMath/manifest.json @@ -1,13 +1,13 @@ { "name": "mpMath", - "version": "0.1.7", + "version": "0.2.0", "description": "微信公众号公式插件.", - "permissions": ["storage", "declarativeContent", "activeTab"], + "permissions": ["storage", "declarativeContent", "activeTab", "scripting"], "background": { - "scripts": ["assets/js/background.js"], - "persistent": false + "background.service_worker": "assets/js/background.js", + "type": "module" }, - "page_action": { + "action": { "default_icon": { "16": "assets/images/mpMath_logo16.png", "32": "assets/images/mpMath_logo32.png", @@ -35,15 +35,20 @@ "run_at": "document_end" }], "web_accessible_resources": [ - "assets/images/formula.png", - "assets/css/weui.css", - "assets/css/popup.css", - "assets/js/jquery-3.4.1.min.js", - "assets/js/mpm-inject.js", - "assets/js/polyfill.min.js", - "assets/js/tex-svg-full.js", - "assets/js/popup.js", - "pages/popup.html" + { + "resources": [ + "assets/images/formula.png", + "assets/css/weui.css", + "assets/css/popup.css", + "assets/js/jquery-3.4.1.min.js", + "assets/js/mpm-inject.js", + "assets/js/polyfill.min.js", + "assets/js/tex-svg-full.js", + "assets/js/popup.js", + "pages/popup.html" + ], + "matches": ["*://mp.weixin.qq.com/*"] + } ], - "manifest_version": 2 + "manifest_version": 3 } \ No newline at end of file diff --git a/mpMath/pages/popup.html b/mpMath/pages/popup.html index 61381e3..0b74691 100644 --- a/mpMath/pages/popup.html +++ b/mpMath/pages/popup.html @@ -32,6 +32,7 @@ +