您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Facebook一键脚本,支持点赞、移除推荐,并根据好友数量条件自动关闭页面。提供UI按钮以控制开关,状态跨页面持久化保存。
当前为
此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.cn-greasyfork.org/scripts/490096/1344912/Facebook%E7%8B%97%E6%8E%A8%E4%B8%93%E7%94%A8.js
- // ==UserScript==
- // @name Facebook狗推专用
- // @namespace http://tampermonkey.net/
- // @version 2.1.1
- // @description Facebook一键脚本,支持点赞、移除推荐,并根据好友数量条件自动关闭页面。提供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; background-color: #4267B2; color: white; cursor: pointer;";
- const likeButton = document.createElement("button");
- likeButton.textContent = "一键点赞";
- likeButton.style = buttonStyle;
- document.body.appendChild(likeButton);
- const removeButton = document.createElement("button");
- removeButton.textContent = "移除推荐";
- removeButton.style = buttonStyle + "bottom: 50px;";
- document.body.appendChild(removeButton);
- const checkButton = document.createElement("button");
- checkButton.textContent = "开始检查好友数量";
- checkButton.style = buttonStyle + "bottom: 150px;";
- document.body.appendChild(checkButton);
- let isChecking = false;
- let intervalId = null;
- const savedState = localStorage.getItem("fb-friendCheckEnabled");
- if (savedState === "true") {
- toggleChecking();
- }
- checkButton.addEventListener("click", toggleChecking);
- function toggleChecking() {
- isChecking = !isChecking;
- localStorage.setItem("fb-friendCheckEnabled", isChecking);
- checkButton.textContent = isChecking
- ? "停止检查好友数量"
- : "开始检查好友数量";
- if (isChecking) {
- startChecking();
- } else if (intervalId) {
- clearInterval(intervalId);
- intervalId = null;
- }
- }
- function startChecking() {
- 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) {
- window.close();
- }
- }
- });
- if (!foundValidLink) {
- window.close();
- }
- }, 500);
- }
- 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() * (1500 - 500) + 500,
- );
- 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);
- });
- })();