Summary
Last week I submitted a few feature ideas for 's Bot Tracker. I reached out to him on Discord and asked about implementing the ideas myself, and he gave me the green light! They have been merged and deployed, so here's a summary of what I did.
Demo:
New Features
Feature 1: Recent Post Suggestions
Now when users type in their username, recent posts eligible for an upvote are displayed as buttons. Users can click these buttons to load the post URL into the form. This feature makes the bottracker even easier to use.
This is done by using the 'steem.api. getAccountHistory' method, filtering for post transactions, creating a new <button> for each post, and appending them to the document body. Each button is given an onclick handler which sets the post_url of the form to the corresponding value. We repeat this process every time an onchage event is emitted from the #bid_details_account_name input.
In a later commit, yabapmatt switched this to the getDiscussionsByAuthorBeforeDate method, which made filtering much easier.
**Edited per mod request: **
I was a little confused by the API of getDiscussionsByAuthorBeforeDate(), shown below:
steem.api.getDiscussionsByAuthorBeforeDate(author, startPermlink, beforeDate, limit, function(err, result) {
console.log(err, result);
});
I was really thrown off by startPermlink - how could I have a link to start from if I knew nothing about the account? There wasn't any documentation telling me that you could just pass in null to start from the beginning, as I later found out.
Instead, I used an approach that had worked in the past for another project - read through the entire account transaction history and parse it. This method requires a lot of data transfer between the server and the client, and a lot more work done by the client. Using getDiscussionsByAuthorBeforeDate() correctly reduces the amount of data transfer dramatically, and offloads most of the work to the server, which is great.
Feature 2: Save username in localStorage
This is a tiny enhancement - the account name used will be saved in localStorage for next time. This prevents the user from having to type it in multiple times.
This is accomplished by writing the account name to localStorage every time it changes. When the page is loaded, we read the account name back and set the input to that value.
Feature 3: Set Minimum Bid in popup automatically
Another tiny enhancement- originally the Default Bid was always set to 0.5 SBD. This changes the Default Bid to be the minimum bid allowed by the bot. Some bots have minimum bids of 2.5SBD, so this feature makes it easier to ensure you're entering a valid bid amount.
Proof of Work
I list my Steemit Username as maxg in the pull request
Posted on Utopian.io - Rewarding Open Source Contributors