【发布时间】:2016-12-18 15:25:37
【问题描述】:
我正在编写一个用户脚本来帮助 Facebook 群组的管理员直接在帖子上执行多项操作。它的目的是在帖子作者姓名附近添加按钮来禁止用户、删除帖子等(浏览群组帖子时)。我已经使用 jQuery 的 append() 函数编写了在用户名附近添加按钮的代码并且它正在工作 - 它将按钮添加到前 14 个人,但是当向下滚动时,Facebook 加载其余的帖子,没有按钮。
我的代码:
// ==UserScript==
// @name admin addon
// @namespace http://facebook.com/
// @version 1.0
// @description an addon that makes you perform admin actions with an ease
// @author mhwq
// @match https://www.facebook.com/groups/1734441496799901/*
// @require http://code.jquery.com/jquery-latest.js
// @require http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js
// @grant GM_addStyle
// @grant GM_getResourceText
// ==/UserScript==
$(document).ready(function() {
$( ".fwb.fcg" ).append(' here go the buttons!');
});
现在怎么办?
有没有什么方法可以让按钮出现在每个群组帖子上,即使是在这些因向下滚动而加载的帖子上?
【问题讨论】:
-
最简单的方法是使用间隔计时器继续检查该类并查看您的按钮是否存在于每个类中。除此之外,您还可以使用更复杂的方法,例如使用 MutaionObservers,甚至弄清楚如何挂钩 facebook ajax 代码
标签: javascript jquery facebook userscripts