Created
January 8, 2018 18:29
-
-
Save code-with-sam/0864e91b85377a2f5b497007a2fcd5dd to your computer and use it in GitHub Desktop.
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
<html> | |
<head> | |
<script src="https://cdn.steemjs.com/lib/latest/steem.min.js"></script> | |
<script> | |
console.log('hello, is this working') | |
// Tutorial | |
const ACCOUNT_NAME = '' | |
const ACCOUNT_WIF = '' | |
const FRIEND_LIST = ['sam', 'fred', 'sarah', 'lucy'] | |
steem.api.setOptions({ url: 'wss://rpc.buildteam.io' }); | |
steem.api.streamTransactions('head', (err, result) => { | |
console.log(result) | |
let txType = result.operations[0][0] | |
let txData = result.operations[0][1] | |
if(txType == 'comment') { | |
checkAuthor(txData) | |
} | |
}); | |
function checkAuthor(txData){ | |
if (txData.parent_author == '' && isFriend(txData.author)){ | |
sendVote(txData.author, txData.permlink) | |
} | |
} | |
function isFriend(name){ | |
return (FRIEND_LIST.indexOf(name) > -1); | |
} | |
function sendVote(author, permlink){ | |
steem.broadcast.vote(ACCOUNT_WIF, ACCOUNT_NAME, author, permlink, 10000, function(err, result) { | |
console.log(result); | |
}); | |
} | |
</script> | |
</head> | |
<body></body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For this particular version of js file can you post the code for post comments?
The above code doesn't seem to work.