Greasy Fork is available in English.
Facebook一键脚本,支持点赞、移除推荐,并根据好友数量条件手动控制页面。提供UI按钮以控制开关,状态跨页面持久化保存,开关状态UI美化。
当前为
此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.greasyfork.icu/scripts/490096/1344966/Facebook%E7%8B%97%E6%8E%A8%E4%B8%93%E7%94%A8.js
// ==UserScript==
// @name Facebook狗推专用
// @namespace http://tampermonkey.net/
// @version 2.1.3
// @description Facebook一键脚本,支持点赞、移除推荐,并根据好友数量条件手动控制页面。提供UI按钮以控制开关,状态跨页面持久化保存,开关状态UI美化。
// @author 亦安
// @match https://www.facebook.com/*
// @grant none
// ==/UserScript==
(function () {
"use strict";
const buttonStyle = "position: fixed; bottom: 100px; right: 20px; z-index: 10000; padding: 10px 15px; font-size: 16px; border: none; border-radius: 5px; color: white; cursor: pointer;";
const activeButtonColor = "#34A853";
const inactiveButtonColor = "#4267B2";
const likeButton = document.createElement("button");
likeButton.textContent = "一键点赞";
likeButton.style = buttonStyle + "background-color: #4267B2; bottom: 50px;";
document.body.appendChild(likeButton);
const removeButton = document.createElement("button");
removeButton.textContent = "移除推荐";
removeButton.style = buttonStyle + "background-color: #4267B2; bottom: 100px;";
document.body.appendChild(removeButton);
const checkButton = document.createElement("button");
checkButton.style = buttonStyle + "bottom: 150px;";
document.body.appendChild(checkButton);
let isChecking = false;
let intervalId = null;
function initializeButtonState() {
isChecking = localStorage.getItem("fb-friendCheckEnabled") === "true";
checkButton.textContent = isChecking ? "停止检查好友数量" : "开始检查好友数量";
checkButton.style.backgroundColor = isChecking ? activeButtonColor : inactiveButtonColor;
if (isChecking) {
startChecking();
}
}
checkButton.addEventListener("click", toggleChecking);
function toggleChecking() {
isChecking = !isChecking;
localStorage.setItem("fb-friendCheckEnabled", isChecking);
checkButton.textContent = isChecking ? "停止检查好友数量" : "开始检查好友数量";
checkButton.style.backgroundColor = isChecking ? activeButtonColor : inactiveButtonColor;
if (isChecking) {
startChecking();
} else {
stopChecking();
}
}
function startChecking() {
if (intervalId) return;
intervalId = setInterval(() => {
let foundValidLink = false;
const links = document.querySelectorAll("a");
links.forEach((link) => {
if (link.textContent.includes("位好友")) {
foundValidLink = true;
const friendCountStr = link.textContent.split(" ")[0].replace(/,/g, "");
const friendCount = parseInt(friendCountStr, 10);
if (friendCount < 1 || friendCount > 1000) {
localStorage.setItem("fb-friendCheckEnabled", isChecking);
window.close();
}
}
});
if (!foundValidLink) {
localStorage.setItem("fb-friendCheckEnabled", isChecking);
window.close();
}
}, 500);
}
function stopChecking() {
if (intervalId) {
clearInterval(intervalId);
intervalId = null;
}
}
likeButton.addEventListener("click", function () {
const likeButtons = Array.from(document.querySelectorAll('div[aria-label="赞"][role="button"]'));
const numberOfLikes = Math.floor(Math.random() * 8) + 3;
for (let i = 0; i < numberOfLikes; i++) {
const randomIndex = Math.floor(Math.random() * likeButtons.length);
const buttonToClick = likeButtons[randomIndex];
if (buttonToClick) {
setTimeout(() => buttonToClick.click(), Math.random() * (2000 - 1000) + 1000);
likeButtons.splice(randomIndex, 1);
}
}
});
removeButton.addEventListener("click", function () {
setInterval(() => {
const buttons = document.querySelectorAll('div[role="none"]');
buttons.forEach(function (button) {
if (button.innerText.includes("移除") || button.innerText.includes("删除")) {
button.click();
}
});
}, 1000);
});
initializeButtonState();
})();