Facebook Block Sponsored Section in Messenger

Removes the section titled "Sponsored" on the right side of Facebook in the messenger area

当前为 2021-07-31 提交的版本,查看 最新版本

// ==UserScript==
// @name        Facebook Block Sponsored Section in Messenger
// @version     0.3
// @description Removes the section titled "Sponsored" on the right side of Facebook in the messenger area
// @author      asheroto
// @match       https://www.facebook.com/
// @namespace   https://gf.qytechs.cn/en/scripts/422348-facebook-block-sponsored-section-in-messenger
// ==/UserScript==

(function () {
	var xpath = function (xpathToExecute) {
		var result = [];
		var nodesSnapshot = document.evaluate(xpathToExecute, document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
		for (var i = 0; i < nodesSnapshot.snapshotLength; i++) {
			result.push(nodesSnapshot.snapshotItem(i));
		}
		return result;
	};

	var thePath = "//div/div[1]/div/div[3]/div/div/div[1]/div[1]/div/div[3]/div/div/div[1]/div/div[1]/span/div";

	var runCount;
	var intv = 500; // Run every 0.5 seconds
	var intvEnd = 5000; // Clear after 5 seconds
	var go = setInterval(pollDOM, intv);
	function pollDOM() {
		runCount += intv; // Add intv value to runCount every time to count the amount of ms ran
		if (runCount >= intvEnd) {
			// Clear interval after intvEnd ms
			clearInterval(go);
		}

		try {
			if (xpath(thePath)[0].children[0].children.length) {
				xpath(thePath)[0].children[0].remove();
			}
		} catch {}
	}
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址