Skip to content

Instantly share code, notes, and snippets.

@inertia186
Last active July 22, 2016 19:47
Show Gist options
  • Save inertia186/afa3f713d104fe2c58ac5f5056cdbbea to your computer and use it in GitHub Desktop.
Save inertia186/afa3f713d104fe2c58ac5f5056cdbbea to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name steemdrp
// @namespace https://steemd.com/
// @version 0.1
// @match https://steemd.com/*
// @grant none
// @require http://code.jquery.com/jquery-latest.js
// @description Adds some derp to steemd.
// @include https://www.steemd.com/*
// ==/UserScript==
metadata = function(e) {
jsonMetadata = e.text();
jsonMetadata = jsonMetadata.substring(1, jsonMetadata.length - 1);
return jQuery.parseJSON(jsonMetadata);
};
countTags = function(e) {
return metadata(e).tags.length;
};
displayTags = function(e) {
retVal = "";
_metadata = metadata(e);
for ( var i = 0 ; i < _metadata.tags.length; i++ ) {
retVal += "\t" + _metadata.tags[i] + "\n";
}
return retVal;
};
postsSelector = '#body > div > div.row > div.col-md-9.col-md-pull-3 > div';
posts = $(postsSelector);
for ( var i = 0 ; i < posts.length ; i++ ) {
post = $(posts[i]);
selector = 'div.advanced > span:nth-child(1) > table > tbody > tr:nth-child(1) > td';
json = $(post.find(selector));
tagCount = countTags(json);
votes = post.find('div:nth-child(2) > div:nth-child(3) > a');
titleElement = post.find('div:nth-child(2) > strong');
title = titleElement.text();
if ( tagCount > 9 ) {
if ( !!votes && votes.length !== 0 && votes.context.innerText.indexOf('👎') != -1 ) {
console.log('Ignoring ' + title + ', already flagged:', votes);
continue;
}
if ( confirm('"' + title + '"\n\n This post has a tag count of: ' + tagCount + "\n\n" + displayTags(json) + "\nDo you want to go to there?") ) {
$('html, body').animate({
scrollTop: post.offset().top
}, 2000);
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment