Skip to content

Instantly share code, notes, and snippets.

@t-kuni
Last active December 3, 2018 12:18
Show Gist options
  • Save t-kuni/05fe1d7a4413d441eaf7551080484b11 to your computer and use it in GitHub Desktop.
Save t-kuni/05fe1d7a4413d441eaf7551080484b11 to your computer and use it in GitHub Desktop.
TwitterのTLをいいねするスクリプト
/**
* 検索結果(ツイート一覧)のツイートすべてにいいねする
*/
function wait() {
return new Promise(function(resolve) {
setTimeout(function() {
resolve();
}, 1000);
});
}
function click() {
var $btn = this;
return new Promise(function(resolve) {
$btn.click();
alert('aa');
resolve();
});
}
function term() {
alert('終了');
}
var p = Promise.resolve();
$("div.tweet").not(".promoted-tweet").not("[data-is-reply-to='true']").find("button.ProfileTweet-actionButton.js-actionFavorite").each(function() {
var $btn = $(this);
if ($btn.is(':hidden'))
return;
// var favCntStr = $btn.find("span.ProfileTweet-actionCountForPresentation").text();
// var favCnt = parseInt(favCntStr);
// if (favCnt > 2) {
// $btn.click();
// }
p = p.then(click.bind($btn)).then(wait);
});
p.finally(term);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment