From 9c13cb1fe97a94911c0e79c834444e157397882d Mon Sep 17 00:00:00 2001 From: Coding Zhang <2291200076@qq.com> Date: Thu, 10 Feb 2022 04:38:18 +0800 Subject: [PATCH] =?UTF-8?q?=E9=98=85=E8=AF=BB=E5=85=A8=E6=96=87=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E5=B1=95=E5=BC=80=E5=85=B3=E8=81=94=E4=B8=BB=E9=9D=A2?= =?UTF-8?q?=E7=89=88=E5=BC=80=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- .../assets/js/expand-full-text/expand.js | 44 +++++++++++++------ 2 files changed, 31 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index eb59a55..4ea277c 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ GitHub仓库:https://github.com/bitdance-team/chrome-extension 郑丽:天气展示功能,翻译功能(使用轻服务云函数构建Api) -张君秋:网页截图功能 +张君秋:网页截图功能,PPT制作 张松:确认页直接跳转功能,番茄钟 diff --git a/packages/shell-chrome/assets/js/expand-full-text/expand.js b/packages/shell-chrome/assets/js/expand-full-text/expand.js index 0801fa5..8b8efe4 100644 --- a/packages/shell-chrome/assets/js/expand-full-text/expand.js +++ b/packages/shell-chrome/assets/js/expand-full-text/expand.js @@ -1,5 +1,5 @@ -$(function() { - console.log("[BitDance extension] 学生助手插件 - 阅读全文自动展开模块加载成功"); + + (async function() { // 删除DOM function removeDOM(querySelector) { let element = document.querySelector(querySelector) @@ -7,22 +7,38 @@ $(function() { element.parentNode.removeChild(element); } } + + // 插件刚开始加载时,先读取一次状态 + var isExpandFulltextActived = true; + isExpandFulltextActived = await new Promise((resolve) => { + chrome.storage.sync.get('State_ExpandFulltext', function (State) { + resolve(State.State_ExpandFulltext); + }); + }); + console.log(`isExpandFulltextActived: ${isExpandFulltextActived}`); + if(!isExpandFulltextActived) + return; + + console.log("[BitDance extension] 学生助手插件 - 阅读全文自动展开模块加载成功"); + switch (window.location.host) { default: break; case "blog.csdn.net": // CSDN博客 - removeDOM(".hide-article-box"); - $(".article_content").removeAttr('style'); - window.onload = () => { - // 代码块自动展开 - document.querySelectorAll("pre").forEach(targetNode => { - removeDOM(".hide-preCode-box"); - if (targetNode.classList.contains("set-code-hide")) { - targetNode.classList.remove("set-code-hide"); - } - }) - } + $(function () { + removeDOM(".hide-article-box"); + $(".article_content").removeAttr('style'); + window.onload = () => { + // 代码块自动展开 + document.querySelectorAll("pre").forEach(targetNode => { + removeDOM(".hide-preCode-box"); + if (targetNode.classList.contains("set-code-hide")) { + targetNode.classList.remove("set-code-hide"); + } + }) + } + }) break; case "www.it1352.com": // it1352 @@ -34,4 +50,4 @@ $(function() { break; } -}) +})();