Last active
December 20, 2015 14:58
-
-
Save patwonder/6150319 to your computer and use it in GitHub Desktop.
Auto Renyao
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @id tieba.baidu.com-auto-renyao@[email protected] | |
// @name Auto Renyao | |
// @version 0.2 | |
// @namespace [email protected] | |
// @author patwonder | |
// @description 自动点人妖 | |
// @include http://tieba.baidu.com/f?*kw=* | |
// @include http://tieba.baidu.com/f?kz=* | |
// @include http://tieba.baidu.com/p/* | |
// @include http://tieba.baidu.com/f?*ct=*z=* | |
// @run-at document-end | |
// ==/UserScript== | |
// License: Public Domain | |
(function(d, w) { | |
Array.prototype.removeDuplicatesNew = function() { | |
Array.prototype.sort.call(this); | |
var prev = undefined; | |
var res = []; | |
for (var i = 0, l = this.length; i < l; i++) { | |
if (this[i] !== prev) | |
res.push(this[i]); | |
prev = this[i]; | |
} | |
return res; | |
}; | |
var $ = unsafeWindow.$; | |
var PageData = unsafeWindow.PageData; | |
function doit() { | |
Array.prototype.filter.call(d.querySelectorAll(".d_name, .tb_icon_author"), function(elem) { | |
return !!elem.querySelector("img.meizhi_vip"); | |
}).map(function(elem) { | |
return JSON.parse(elem.dataset.field).user_id; | |
}).removeDuplicatesNew().forEach(function(user_id) { | |
$.ajax({ | |
type: "post", | |
url: "/encourage/post/meizhi/vote", | |
data: { | |
content: "", | |
tbs: PageData.tbs, | |
fid: PageData.forum.id || PageData.forum.forum_id, | |
kw: PageData.forum.name, | |
uid: user_id, | |
scid: PageData.user.id || 0, | |
vtype: "renyao", | |
ie: "utf-8", | |
vcode: "" | |
}, | |
dataType: "json" | |
}).success(function(data) { | |
console.log("renyao[" + user_id + "] " + JSON.stringify(data)); | |
}).error(function(jqxhr, status, ex) { | |
console.error("renyao[" + user_id + "] fail: " + status + "\n Exception: " + ex); | |
}); | |
}); | |
} | |
w.addEventListener("DOMContentLoaded", doit); | |
})(document, window); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment