Skip to content

Commit

Permalink
修复不支持Chrome新版本的问题(update to manifest V3) (#1)
Browse files Browse the repository at this point in the history
* 转换至manifest V3

* 修复所有错误
  • Loading branch information
TRSWNCA authored Aug 3, 2023
1 parent 57daec2 commit 3f0f5b0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 17 deletions.
5 changes: 3 additions & 2 deletions mpMath/assets/js/content-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,22 @@ setTimeout(function () {
}, 1000);

// 等待文档加载完毕
chrome.extension.sendMessage({}, function (response) {
chrome.runtime.sendMessage({}, function (response) {
var readyStateCheckInterval = setInterval(function () {
if (document.readyState === 'complete') {
clearInterval(readyStateCheckInterval);

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');
Expand Down
35 changes: 20 additions & 15 deletions mpMath/manifest.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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
}
1 change: 1 addition & 0 deletions mpMath/pages/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<button id="cancel" class="weui-desktop-btn weui-desktop-btn_default">取消</button>
</div>
</div>
<script id="MathJax-script" async src="../assets/js/tex-svg-full.js"></script>
<script src="../assets/js/popup.js"></script>
</body>

Expand Down

0 comments on commit 3f0f5b0

Please sign in to comment.