Greasy Fork

Greasy Fork is available in English.

ACT.谷歌.MO.Stay

留在网络而非应用,移除谷歌微件和APP推广横幅。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name               ACT.Google.MO.Stay
// @name:zh-CN         ACT.谷歌.MO.Stay
// @description        Stay in web not app, Google Widget and APP Banner Remove.
// @description:zh-CN  留在网络而非应用,移除谷歌微件和APP推广横幅。
// @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              *://*.google.com/*
// @match              *://*.google.com.hk/*
// @grant              none
// @inject-into        content
// @run-at             document-start
// ==/UserScript==

(function () {
	"use strict";

	function cleaner() {
		const careful_remove = (e) =>
			!e ||
			e.className == "main" ||
			e.id == "gb-main" ||
			e.remove() ||
			console.info("REMOVE:", e);
		// Index - Bottom App Banner
		document.querySelectorAll("mobile-promo").forEach((e) => {
			// console.info('GOTCHA:', e); // DEBUG
			careful_remove(e.closest("body>div"));
		});
		document.querySelectorAll("g-raised-button").forEach((e) => {
			if (e.textContent.includes("Try it") || e.textContent.includes("试用")) {
				// console.info('GOTCHA:', e); // DEBUG
				careful_remove(e.closest("body>div[style]"));
			}
		});
		// Search - Bottom Widget Banner
		document.querySelectorAll("button").forEach((e) => {
			if (e.textContent == "Get the app" || e.textContent == "获取该应用") {
				// console.info('GOTCHA:', e); // DEBUG
				careful_remove(e.closest("body>div[id][style]"));
			}
		});
	}

	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 */
#center_col #taw { display: none !important; } /* AD */
#center_col #tads { 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 });
	}
})();