自动展开

自动展开文档 隐藏部分;长期维护、全平台支持:CSDN、简书、知乎、百家号、百度资讯、百度经验、百度知道、百度贴吧、百度新闻、新浪新闻、腾讯新闻、搜狐新闻、网易新闻、凤凰新闻、CSDN手机版、简书手机版、知乎手机版、百家号手机版、百度资讯手机版、百度经验手机版、百度知道手机版、百度贴吧手机版、百度新闻手机版、新浪新闻手机版、腾讯新闻手机版、搜狐新闻手机版、网易新闻手机版、凤凰新闻手机版

Versión del día 12/3/2022. Echa un vistazo a la versión más reciente.

Tendrás que instalar una extensión para tu navegador como Tampermonkey, Greasemonkey o Violentmonkey si quieres utilizar este script.

Necesitarás instalar una extensión como Tampermonkey o Violentmonkey para instalar este script.

Necesitarás instalar una extensión como Tampermonkey o Violentmonkey para instalar este script.

Necesitarás instalar una extensión como Tampermonkey o Userscripts para instalar este script.

Necesitará instalar una extensión como Tampermonkey para instalar este script.

Necesitarás instalar una extensión para administrar scripts de usuario si quieres instalar este script.

(Ya tengo un administrador de scripts de usuario, déjame instalarlo)

Necesitará instalar una extensión como Stylus para instalar este estilo.

Necesitará instalar una extensión como Stylus para instalar este estilo.

Necesitará instalar una extensión como Stylus para instalar este estilo.

Necesitará instalar una extensión del gestor de estilos de usuario para instalar este estilo.

Necesitará instalar una extensión del gestor de estilos de usuario para instalar este estilo.

Necesitará instalar una extensión del gestor de estilos de usuario para instalar este estilo.

(Ya tengo un administrador de estilos de usuario, déjame instalarlo)

// ==UserScript==
// @name         自动展开
// @version      1.2.0
// @namespace    https://github.com/AirBashX/AutoUnfold/
// @homepage     https://github.com/AirBashX/UserScript
// @author       airbash
// @description  自动展开文档	隐藏部分;长期维护、全平台支持:CSDN、简书、知乎、百家号、百度资讯、百度经验、百度知道、百度贴吧、百度新闻、新浪新闻、腾讯新闻、搜狐新闻、网易新闻、凤凰新闻、CSDN手机版、简书手机版、知乎手机版、百家号手机版、百度资讯手机版、百度经验手机版、百度知道手机版、百度贴吧手机版、百度新闻手机版、新浪新闻手机版、腾讯新闻手机版、搜狐新闻手机版、网易新闻手机版、凤凰新闻手机版
// @match      	 *://*.jianshu.com/*
// @match        *://blog.csdn.net/*
// @match        *://ask.csdn.net/questions/*
// @match        *://*.it1352.com/*
// @match        *://www.zhihu.com/question/*
// @match        *://jingyan.baidu.com/article*
// @match        *://zhidao.baidu.com/question*
// @match        *://tieba.baidu.com/p*
// @match        *://baijiahao.baidu.com/s*
// @match        *://mbd.baidu.com/newspage/data/*
// @match        *://news.baidu.com/news*
// @match        *://m.baidu.com/sf_baijiahao/*
// @match        *://*.sina.cn/*
// @match        *://3g.163.com/*
// @match        *://m.sohu.com/a/*
// @match        *://xw.qq.com/*
// @match        *://*.ifeng.com/c/*
// @match        *://m.thepaper.cn/newsDetail_forward*
// @match        *://m.bjnews.com.cn/detail/*
// @match        *://world.huanqiu.com/article/*
// @match        *://3g.dxy.cn/*
// @run-at       document-body
// @icon         data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAcQAAAHECAYAAACnX1ofAAAABmJLR0QA/wD/AP+gvaeTAAAMeklEQVR4nO3cTY4dVxnH4Zd0Rpll4B1kwgpgBQyQsNhCBkwslsEgA0RAQgLyDZJDIrEExCLwCpCCYMSHxAAjYRh0l+Nud92uuvc9db6eR/rPzym7/dORrI4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADjIVe0DTObdiPhXRPyt9kGA3b4XEW9HxJ9rHwR694OIeBERf4mIb1Y+C7DPdyPi3xHxz4j4duWzQNeWGP7vZqII/VhiuPz8iiKc6W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IYA3BBFMQTghiiKIQA3RFEMAbgxcxTFEIBbZoyiGAJwr5miKIYAnDRDFMUQgE1GjqIYArDLiFEUQwDOMlIUxRCAi4wQRTEEIEXPURRDAFL1GEUxBKCInqIohgAU1UMUxRCAQ7QcRTEE4FAtRlEMAaiipSiKIQBVtRBFMQSgCTWjKIYANKVGFMUQgCYdGUUxBKBpR0RRDAHoQskoiiEAXSkRRTEEoEuZURRDALqWEUUxBGAIl0RRDAEYyjlRFEMAhrQnimIIwNC2RFEMAZjCqSiKIQBTuS+KYgjAlF6NohgCMLWriPh1iCEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA3fo/tBf+1ozpM9IAAAAASUVORK5CYII=
// @grant        none
// @license      GPL-3.0
// ==/UserScript==
(function () {
	/**
	 * 网站列表
	 * @type {name/url/操作类型}
	 */
	var websites = [
		{
			name: "CSDN",
			url: "blog.csdn.net",
			handles: [
				//自动展开代码块
				{
					type: "click",
					item: ".look-more-preCode",
				},
				//移动版:弹出窗口
				{
					type: "display",
					item: ".weixin-shadowbox",
				},
				//移动版:下载App按钮
				// {
				// 	type: "display",
				// 	item: ".feed-Sign-span",
				// },
				//移动版:阅读全文
				{
					type: "display",
					item: ".btn_mod",
				},
				{
					type: "height",
					item: ".article_content",
				},
				{
					type: "display",
					item: ".readall_box",
				},
				//移动版:展开评论
				{
					type: "click",
					item: ".btn_comment_readmore",
				},
			],
		},
		{
			name: "CSDN问答",
			url: "ask.csdn.net/questions",
			handles: [
				//展开全部
				{
					type: "display",
					item: ".expandBtn",
				},
				{
					type: "height",
					item: ".normal-style",
				},
			],
		},
		{
			name: "it1352",
			url: "it1352.com",
			handles: [
				//查看全文:解除公众号限制
				{
					type: "display",
					item: ".arc-body-main-more",
				},
				{
					type: "height",
					item: ".arc-body-main",
				},
			],
		},
		{
			name: "简书",
			url: "jianshu.com/p",
			handles: [
				//移动版:弹出窗口
				{
					type: "display",
					item: ".download-app-guidance",
				},
				//移动版:下载App按钮
				// {
				// 	type: "display",
				// 	item: ".call-app-btn",
				// },
				//移动版:阅读全文
				{
					type: "display",
					item: ".collapse-tips",
				},
				{
					type: "height",
					item: ".collapse-free-content",
				},
				{
					type: "display",
					item: ".copyright",
				},
				// 移动版:允许滑动
				{
					type: "overflow",
					item: "body",
				},
			],
		},
		{
			name: "知乎",
			url: "www.zhihu.com/question",
			handles: [
				//显示全部(问题描述)
				{
					type: "click",
					item: ".QuestionRichText-more",
				},
				//移动版:下载弹窗
				{
					type: "display",
					item: ".ModalWrap",
				},
				//移动版:允许滑动
				{
					type: "overflow",
					item: "body",
				},
				//移动版:展开阅读全文+查看问题描述
				{
					type: "display",
					item: ".ContentItem-rightButton",
				},
				{
					type: "height",
					item: ".RichContent-inner",
				},
				//移动版:悬浮按钮
				// {
				// 	type: "display",
				// 	item: ".OpenInAppButton",
				// },
				//移动版:主页悬浮
				// {
				// 	type: "display",
				// 	item: ".DownloadGuide-inner",
				// }
			],
			//删除透明遮挡
			fun: function () {
				var item = document.querySelector(".RichContent-inner");
				item.style.setProperty("-webkit-mask-image", "unset", "important");
			},
		},
		{
			name: "百度经验",
			url: "jingyan.baidu.com/article",
			handles: [
				{
					type: "display",
					item: ".read-whole-mask",
				},
				{
					type: "height",
					item: ".exp-content-container",
				},
				//移动版:展开内容
				{
					type: "click",
					item: ".more-img-opt",
				},
			],
		},
		{
			name: "百度知道",
			url: "zhidao.baidu.com/question",
			handles: [
				{
					type: "display",
					item: ".wgt-best-mask",
				},
				{
					type: "height",
					item: ".best-text",
				},
				{
					type: "display",
					item: ".wgt-answers-mask",
				},
				{
					type: "height",
					item: ".answer-text",
				},
				{
					type: "click",
					item: "#show-answer-hide",
				},
				{
					type: "click",
					item: ".show-hide-dispute",
				},
				//移动版:展开内容
				{
					type: "display",
					item: ".w-detail-display-btn",
				},
				{
					type: "height",
					item: ".w-detail-container",
				},
				//移动版:更多回答
				{
					type: "tap",
					item: ".show-more-replies",
				},
			],
		},
		{
			name: "百度贴吧",
			url: "tieba.baidu.com/p",
			handles: [
				//自动展开图片
				{
					type: "display",
					item: ".replace_tip",
				},
				{
					type: "height",
					item: ".replace_div",
				},
				//自动展开回复
				{
					type: "click",
					item: ".j_lzl_m",
				},
				//移动版:弹出窗口
				{
					type: "display",
					item: ".tb-backflow-defensive",
				},
				//移动版:允许滑动
				{
					type: "overflow",
					item: "body",
				},
			],
		},
		{
			name: "百家号",
			url: "baijiahao.baidu.com/s",
			handles: [
				//移动版:弹出窗口
				{
					type: "display",
					item: ".layer-wrap",
				},
				{
					type: "overflow",
					item: "body",
				},
				//移动版:阅读全文
				{
					type: "display",
					item: ".oPadding",
				},
				{
					type: "height",
					item: ".mainContent",
				},
				//移动版:悬浮按钮
				// {
				// 	type: "display",
				// 	item: ".undefined",
				// },
			],
		},
		{
			name: "百度app新闻",
			url: "mbd.baidu.com/newspage/data",
			handles: [
				//类似于百家
				//移动版:弹出窗口
				{
					type: "display",
					item: ".layer-wrap",
				},
				{
					type: "overflow",
					item: "body",
				},
				//移动版:阅读全文
				{
					type: "display",
					item: ".height-fold",
				},
				{
					type: "height",
					item: ".dynamic-item",
				},

				//类似于百度
				//移动版:阅读全文
				{
					type: "display",
					item: ".packupButton",
				},
				{
					type: "height",
					item: ".mainContent",
				},
				//移动版:悬浮按钮
				// {
				// 	type: "display",
				// 	item: ".GcwrDCd4cJnZ_u",
				// },
			],
		},
		{
			name: "百度资讯",
			url: "m.baidu.com/sf_baijiahao",
			handles: [
				//移动版:下载弹窗
				{
					type: "display",
					item: ".layer-wrap",
				},
				{
					type: "overflow",
					item: "body",
				},
				//移动版:展开全文
				{
					type: "display",
					item: ".oPadding",
				},
				{
					type: "height",
					item: ".mainContent",
				},
				//移动版:悬浮按钮
				// {
				// 	type: "display",
				// 	item: ".undefined",
				// },
			],
		},
		{
			name: "百度新闻",
			url: "news.baidu.com/news#/detail",
			handles: [
				//移动版:阅读全文
				{
					type: "display",
					item: ".show-more-btn-container",
				},
				{
					type: "display",
					item: ".show-more-end",
				},
				{
					type: "height",
					item: ".detail-content-main",
				},
			],
		},
		{
			name: "新浪新闻",
			url: "sina.cn",
			handles: [
				//移动版:展开
				{
					type: "display",
					item: ".look_more",
				},
				{
					type: "height",
					item: ".s_card",
				},
				//other:悬浮下载按钮
				// {
				// 	type: "display",
				// 	item: "#float-btn",
				// },
			],
		},
		{
			name: "网易新闻",
			url: "3g.163.com",
			handles: [
				//移动版:展开
				{
					type: "display",
					item: ".show_article",
				},
				{
					type: "height",
					item: "article",
				},
			],
		},
		{
			name: "搜狐新闻",
			url: "m.sohu.com/a",
			handles: [
				//移动版:展开
				{
					type: "click",
					item: ".look-all",
				},
			],
		},
		{
			name: "腾讯新闻",
			url: "xw.qq.com/cmsid",
			handles: [
				//移动版:展开
				{
					type: "display",
					item: ".icon-content-more",
				},
				{
					type: "display",
					item: ".mask",
				},
				{
					type: "height",
					item: ".packed",
				},
			],
		},
		{
			name: "凤凰新闻",
			url: "i.ifeng.com/c/",
			handles: [
				//移动版:点击展开全文
				{
					type: "display",
					item: "[class^=tip]",
				},
				{
					type: "height",
					item: "[class^=main_content]",
				},
				{
					type: "display",
					item: "[class^=more]",
				},
				//移动版:展开
				{
					type: "click",
					item: "[class^=unfoldIcon]",
				},
			],
		},
		{
			name: "澎湃新闻",
			url: "m.thepaper.cn/newsDetail_forward",
			handles: [
				//移动版:展开全文
				{
					type: "display",
					item: "#clickForMore",
				},
				{
					type: "height",
					item: ".newsdetail_body",
				},
			],
		},
		{
			name: "新京报",
			url: "m.bjnews.com.cn/detail/",
			handles: [
				//移动版:展开全文
				{
					type: "click",
					item: ".shade-box",
				},
			],
		},
		{
			name: "环球网",
			url: "world.huanqiu.com/article",
			handles: [
				//移动版:展开全文
				{
					type: "click",
					item: ".unfold-btn",
				},
				{
					type: "height",
					item: ".newsdetail_body",
				},
			],
		},
		{
			name: "丁香园",
			url: "3g.dxy.cn",
			handles: [
				//移动版:展开全部
				{
					type: "height",
					item: ".topic-body",
				},
				{
					type: "display",
					item: ".tapToReadAll"
				},
				//移动版:显示第一条评论
				{
					type: "height",
					item: ".dicussion-text",
				},
			],
			//减少定时器对页面的影响
			fun: function () {
				var item = document.querySelector(".topic-body");
				if(item !=null){
					if (item.getAttribute("class") != "topic-body") {
					item.setAttribute("class", "topic-body");
					}
				}
				
			},
		},
	];
	var time = 0;
	var interval = setInterval(() => {
		if (++time == 100) {
			clearInterval(interval);
		}
		for (var website of websites) {
			if (location.href.indexOf(website.url) != -1) {
				if (website.fun) {
					website.fun();
				}
				for (var handle of website.handles) {
					var items = document.querySelectorAll(handle.item);
					if (items.length != 0) {
						if (handle.type == "display") {
							//隐藏遮挡部分
							for (var item of items) {
								item.style.display = "none";
							}
						} else if (handle.type == "height") {
							//加长内容部分
							for (var item of items) {
								item.style.setProperty("height", "unset", "important");
								item.style.setProperty("maxHeight", "unset", "important");
								item.style.setProperty("minHeight", "unset", "important");
							}
						} else if (handle.type == "overflow") {
							//防止无法滑动
							for (var item of items) {
								item.style.setProperty("overflow", "unset", "important");
							}
						} else {
							//模拟点击,后续可能取消
							for (var item of items) {
								if (item != null && item.getAttribute("opened") != "yes") {
									item.click();
									item.setAttribute("opened", "yes");
								}
							}
						}
					}
				}
			}
		}
	}, 100);
})();