🎉 欢迎访问GreasyFork.Org 镜像站!本镜像站由公众号【爱吃馍】搭建,用于分享脚本。联系邮箱📮

Greasy fork 爱吃馍镜像

ACT.Zhihu.DM.Stay

Stay in web not app, browsing experience optimization.

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

You will need to install an extension such as Tampermonkey to install this script.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

// ==UserScript==
// @name               ACT.Zhihu.DM.Stay
// @name:zh-CN         ACT.知乎.DM.Stay
// @description        Stay in web not app, browsing experience optimization.
// @description:zh-CN  留在网络而非应用,网站浏览体验优化。
// @author             ACTCD
// @version            20220722.1
// @license            GPL-3.0-or-later
// @namespace          ACTCD/Userscripts
// @supportURL         https://github.com/ACTCD/Userscripts#contact
// @homepageURL        https://github.com/ACTCD/Userscripts
// @match              *://*.zhihu.com/*
// @grant              none
// @inject-into        content
// @run-at             document-start
// ==/UserScript==

(function () {
	"use strict";

	if (location.href == "https://www.zhihu.com/signin?next=%2F")
		location.replace("https://www.zhihu.com/explore"); // Index Login jump

	function cleaner() {
		//=D
		document.querySelector(".Modal-wrapper button.Modal-closeButton")?.click(); // Cover Login banner
		//=D/search
		document
			.querySelector(".SearchBar-tool input")
			?.setAttribute("placeholder", ""); // Recommended
		document
			.querySelectorAll(".AutoComplete-menu .AutoComplete-group")
			.forEach((e) => {
				e.querySelector(".SearchBar-topSearchItem") &&
					e.style.setProperty("display", "none"); // Recommended
			});
		//=D/question
		document.querySelector(".QuestionHeader .QuestionRichText-more")?.click(); // Content collapse
		document
			.querySelector(".QuestionHeader-footer.is-fixed")
			?.classList.remove("is-fixed"); // Fix space
		//=M/search
		document
			.querySelector(".MobileAppHeader-searchBox input[type=search]")
			?.setAttribute("placeholder", ""); // Recommended
		//=M/question
		document.querySelector(".ContentItem-expandButton")?.click(); // Content collapse
		document
			.querySelector(".RichContent-actions.is-fixed")
			?.classList.remove("is-fixed"); // Fix space
		//=Common
		document
			.querySelectorAll('a[href^="https://link.zhihu.com/"]')
			.forEach((e) => {
				const url = new URL(e.href);
				e.href = url.searchParams.get("target") ?? e.href;
			});
	}

	new MutationObserver(cleaner).observe(document, {
		subtree: true,
		childList: true,
	});

	function DOMContentLoaded() {
		cleaner();
	}

	if (document.readyState === "loading") {
		document.addEventListener("DOMContentLoaded", DOMContentLoaded);
	} else {
		DOMContentLoaded();
	}

	const style = document.createElement("style");
	style.textContent = `/* Global style */
/*=D/question */
.Question-mainColumnLogin { display: none !important; } /* Embed Login banner */
.List .Pc-word { display: none !important; } /* AD */
.Sticky .AppBanner { display: none !important; } /* Embed App banner */
.Sticky .Pc-card { display: none !important; } /* AD */
/*=M */
.MobileAppHeader-downloadLink { visibility: hidden !important; } /* Top App banner */
.OpenInAppButton,.OpenInApp { display: none !important; } /* Float App banner */
/*=M/explore */
#js-openInApp { display: none !important; } /* Top App banner */
/*=M/search */
.MobileHotSearch-container { display: none !important; } /* Recommended */
.MobileHistorySearch-container { padding-top: 15px !important; } /* Fix space */
/*=M/question */
.RelatedReadings { display: none !important; } /* Recommended */
.HotQuestions { display: none !important; } /* Recommended */
.MBannerAd { display: none !important; } /* AD */
`;

	if (document.head) {
		document.head.append(style);
	} else {
		new MutationObserver((mutationList, observer) => {
			document.head && (observer.disconnect(), document.head.append(style));
		}).observe(document, { subtree: true, childList: true });
	}
})();