Last active
October 9, 2020 09:44
-
-
Save rirufa/2d2e766609dcd61f53109eba97fac069 to your computer and use it in GitHub Desktop.
twitterのDMグループにユーザーをまとめて追加する奴
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
getElementsByXPath = function(expression, parentElement) { | |
var r = [] | |
var x = document.evaluate(expression, parentElement || document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null) | |
for (var i = 0, l = x.snapshotLength; i < l; i++) { | |
r.push(x.snapshotItem(i)) | |
} | |
return r | |
} | |
//ここにユーザーネームを追加する | |
usernames = ["@oqoobo","@145pokpok","@test","@test2","@gigazine"]; | |
//追加できなかったユーザーネームの一覧 | |
failed_names = []; | |
for(username of usernames) | |
{ | |
var element = document.querySelector('input[placeholder="ユーザーを検索"]'); | |
element.value= username; | |
element = getElementsByXPath('//form[@aria-label="ユーザーを検索"]//span[text()="'+ username + '"]'); | |
if(element.length == 0) | |
failed_names.push(username); | |
else | |
element[0].click(); | |
} | |
alert("add usernames. It print usernames which failed to add in console"); | |
console.log(failed_names); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment