1
0
mirror of https://gitee.com/bitdance-team/chrome-extension synced 2025-01-10 13:48:14 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee

阅读全文自动展开关联主面版开关

This commit is contained in:
程序员小墨 2022-02-10 04:38:18 +08:00
parent 5552577c0b
commit 9c13cb1fe9
2 changed files with 31 additions and 15 deletions

View File

@ -42,7 +42,7 @@ GitHub仓库https://github.com/bitdance-team/chrome-extension
郑丽天气展示功能翻译功能使用轻服务云函数构建Api 郑丽天气展示功能翻译功能使用轻服务云函数构建Api
张君秋:网页截图功能 张君秋:网页截图功能PPT制作
张松:确认页直接跳转功能,番茄钟 张松:确认页直接跳转功能,番茄钟

View File

@ -1,5 +1,5 @@
$(function() {
console.log("[BitDance extension] 学生助手插件 - 阅读全文自动展开模块加载成功"); (async function() {
// 删除DOM // 删除DOM
function removeDOM(querySelector) { function removeDOM(querySelector) {
let element = document.querySelector(querySelector) let element = document.querySelector(querySelector)
@ -7,22 +7,38 @@ $(function() {
element.parentNode.removeChild(element); 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) { switch (window.location.host) {
default: default:
break; break;
case "blog.csdn.net": // CSDN博客 case "blog.csdn.net": // CSDN博客
removeDOM(".hide-article-box"); $(function () {
$(".article_content").removeAttr('style'); removeDOM(".hide-article-box");
window.onload = () => { $(".article_content").removeAttr('style');
// 代码块自动展开 window.onload = () => {
document.querySelectorAll("pre").forEach(targetNode => { // 代码块自动展开
removeDOM(".hide-preCode-box"); document.querySelectorAll("pre").forEach(targetNode => {
if (targetNode.classList.contains("set-code-hide")) { removeDOM(".hide-preCode-box");
targetNode.classList.remove("set-code-hide"); if (targetNode.classList.contains("set-code-hide")) {
} targetNode.classList.remove("set-code-hide");
}) }
} })
}
})
break; break;
case "www.it1352.com": // it1352 case "www.it1352.com": // it1352
@ -34,4 +50,4 @@ $(function() {
break; break;
} }
}) })();