Permalink
Browse files

Steemplus 1.7

Add Beneficiaries Post option
  • Loading branch information...
stoodkev committed Nov 1, 2017
1 parent 9c63fec commit dd75e59b3d6eba6487c27b7aaa935bdf4d10ff08
View
@@ -0,0 +1,42 @@
.beneficiaries, .post { list-style-type: none; margin-bottom: 1em; margin-left: 0; text-align: left; display: block; width: 100%;}
.beneficiaries:first-of-type{margin-top: 2em;}
.benef_elt{display: inline-block; width: 40%;
}
.sign{
width: 10%;
text-align: center;
}
.beneficiaries input, .post input {width: 90%; display: inline-block;
padding-bottom: 1em;}
.close{
color: #A52A2A;
display: inline-block;
height: 100%;
vertical-align: center;
font: 1.2em arial, sans-serif;
cursor: pointer;
text-decoration: none;
margin-left: 5%;
text-shadow: 0 1px 0 #fff;
}
.close:after {
content: ''; /* UTF-8 symbol */
}
.inline_button{
display: inline-block;
}
.inline_button button{
.UserWallet__buysp button hollow
}
View
@@ -20,7 +20,7 @@ cursor:pointer; display:inline-block;
margin:auto;
width: 300px;
height: 300px;
background: url("chrome-extension://__MSG_@@extension_id__/img/logo.png") no-repeat ;
background: url("chrome-extension://__MSG_@@extension_id__/img/logo.png") no-repeat ;
animation: spin 2s linear infinite;
}
View
@@ -17,7 +17,7 @@ body {
width: 100%;
height: 7px;
border-radius: 5px;
background: #f1f1f1;
background: #e0e0e0;
outline: none;
opacity: 0.7;
-webkit-transition: .2s;
View
BIN +7.83 KB img/close.png
Binary file not shown.
View
@@ -0,0 +1,203 @@
/**
* Created by quent on 10/27/2017.
*/
var website='';
var created_benef=false;
var beneficiaries;
const STEEM_PLUS_FEED=5;
$(document).ready(function(){
if(window.location.href.match('steemit.com')) {
website='steemit';
if(window.location.href.match(/submit/))
addBeneficiariesButton();
$(document).click(function(){
if(window.location.href.match(/submit/)&&!created_benef){addBeneficiariesButton();
}
if(!window.location.href.match(/submit/)){created_benef=false;
}
});
}
else if(window.location.href.match('steemit.com'))
{
website='busy';
}
});
function addBeneficiariesButton(){
var benef_div = document.createElement('div');
benef_div.style.width = '100%';
benef_div.style.marginBottom = '2em;';
var benef_button = document.createElement('input');
benef_button.value = 'Add beneficiaries';
benef_button.type='button';
benef_button.className = 'UserWallet__buysp button hollow benef';
benef_div.appendChild(benef_button);
$('.vframe__section--shrink')[$('.vframe__section--shrink').length-1].after(benef_div);
$('.benef').click(function(){
$('.benef').parent().after('<li class="beneficiaries"><div class="benef_elt"><span class="sign" >@</span><input type="text" placeholder="username"></div><div class="benef_elt" style="width: 15%;"><input style="width: 75%;" type="number" placeholder="10"><span class="sign" >%</span></div><a class="close"></a> </li>');
if($('.close').length===1) {
$('.vframe__section--shrink button').hide();
if($('.post').length===0) {
$('.beneficiaries').after('<h5 style="text-align: left;">Posted By</h5><li class="post"><div class="benef_elt"><span class="sign" >@</span><input type="text" placeholder="author"></div><div class="benef_elt" "><input type="password" placeholder="Private Posting WIF*"></div><div class="inline_button"><input type="button" class="UserWallet__buysp button hollow postbutton" value="Post"/></div> <p>* Your WIF is stored locally for your safety. SteemConnect integration coming soon.</p></li>');
$('.postbutton').click(function (){if(isEverythingFilled()) postBeneficiaries();});
chrome.storage.local.get(['username','wif'], function (items) {
$('.post input').eq(0).val(items.username);
$('.post input').eq(1).val(items.wif);
});
}
else
$('h5,.post').show();
}
setCloseListener();
});
created_benef=true;
}
function setCloseListener(){
$('.close').each(function(i){
$(this).off("click");
$(this).on("click",function() {
$('.beneficiaries')[i].remove();
if($('.close').length===0) {
$('.vframe__section--shrink button').show();
$('h5,.post').hide();
}
setCloseListener();
});
});
}
function isEverythingFilled()
{
beneficiaries=[];
if($('.vframe__section--shrink button').is(":disabled"))
{
alert("Please enter a title, body and tags to your post!");
return false;
}
var total_percent=0;
var hasEmpty=0;
var hasWrongPercent=0;
$('.beneficiaries').each(function(i,e){
hasEmpty+=$(e).find('input').eq(0).val()===''?1:0;
hasEmpty+=$(e).find('input').eq(1).val()===''?1:0;
hasWrongPercent+=($(e).find('input').eq(1).val()<=0||isNaN($(e).find('input').eq(1).val())||$(e).find('input').eq(1).val()>100)?1:0;
total_percent+=parseInt($(e).find('input').eq(1).val());
beneficiaries.push({
account: $(e).find('input').eq(0).val(),
weight: 100*parseInt($(e).find('input').eq(1).val())
});
});
if(hasEmpty!==0)
{
alert("Please enter the name and percentage for each beneficiary!");
return false;
}
if(hasWrongPercent!==0)
{
alert("Percentage should be greater than 0 and smaller are equal to 100!");
return false;
}
if(total_percent>95)
{
alert("Total beneficiary rewards must be smaller are equal to 95%!");
return false;
}
if($('.post input').eq(0).val()===''||$('.post input').eq(1).val()==='')
{
alert("Please enter your username and private posting key!");
return false;
}
return true;
}
function postBeneficiaries()
{
var tags=$('.vframe input').eq(2).val().split(' ');
var author=$('.post input').eq(0).val();
var wif=$('.post input').eq(1).val();
var title=$('.vframe input').eq(0).val();
var permlink=$('.vframe input').eq(0).val().toLowerCase()
.replace(/ /g,'-')
.replace(/[^\w-]+/g,'');
var body=$('.vframe textarea').eq(0).val();
var sbdpercent=$(".vframe select option:selected").index()===0?0:10000;
beneficiaries.push({
account: 'steem-plus',
weight: 100*STEEM_PLUS_FEED
});
var operations = [
['comment',
{
parent_author: '',
parent_permlink: tags[0],
author: author,
permlink: permlink,
title: title,
body: body,
json_metadata : JSON.stringify({
tags: tags,
app: 'steemplus'
})
}
],
['comment_options', {
author: author,
permlink: permlink,
max_accepted_payout: '100000.000 SBD',
percent_steem_dollars: sbdpercent,
allow_votes: true,
allow_curation_rewards: true,
extensions: [
[0, {
beneficiaries: beneficiaries
}]
]
}]
];
steem.broadcast.send(
{ operations: operations, extensions: [] },
{ posting: wif },
function(e, r) {
if (e) {
console.log(e.message);
if(e.message.includes('must exist.')) alert('Error. One of the beneficiaries doesn\'t exist.');
else if(e.message.includes('You may only post once')) alert('Error. You can post only every 5 minutes.');
else alert('Error. Check your credentials.');
} else {
chrome.storage.local.set({
username:$('.post input').eq(0).val(),
wif:$('.post input').eq(1).val()
}).then((result)=>{
window.location.replace('https://steemit.com');});
}
});
}
View
@@ -26,7 +26,7 @@ function checkLoad(){
createButton();
}
else {
setTimeout(checkLoad, 1000); // checkLoad again in a second
setTimeout(checkLoad, 1000); // addBeneficiariesButton again in a second
}
}
@@ -56,7 +56,7 @@ function createButton() {
'<span style="min-width: 5rem; height: inherit; background-color: transparent; border: none;">SP</span></span></div><div style="margin-bottom: 0.6rem;"><a id="max_sp" style="border-bottom: 1px dotted rgb(160, 159, 159); cursor: pointer;">'+
'Max: '+getMaxSP()+' SP</a></div></div></div><div class="row"><div class="column"><span><input type="button" disabled="" class="UserWallet__buysp button hollow delegate" id="bd" value="Submit"/></span></div></div></form></div></div></div>';
$('body').append(div);
$('.close-button').click(function(){console.log('close');$('#overlay_delegate').remove();});
$('.close-button').click(function(){$('#overlay_delegate').remove();});
$('#max_sp').click(function(){$('input[name=amount]').val(getMaxSP()+'');});
$('form input').blur(function () {
if(parseFloat($('input[name=amount]').val())>=0&&parseFloat($('input[name=amount]').val())<=getMaxSP()&&$('input[placeholder="Your account"]').val()!==''&&$('input[placeholder="Send to account"]').val()!=='')
View
@@ -24,7 +24,7 @@ if(window.location.href.match('steemit.com')) {
post_div='.PostsIndex__left';
reblog=".PostSummary__reblogged_by";
ad_post="li:first-child .entry-title a";
feed_url = document.getElementsByClassName("Header__top-steemit")[0].firstChild.href;
feed_url = document.getElementsByClassName("Header__top-logo")[0].firstChild.href;
feedplus_url=feed_url+"#plus";
user = feed_url.split('@')[1].split('/')[0];
menu_list=document.getElementsByClassName("HorizontalMenu")[0];
@@ -56,7 +56,7 @@ else if(window.location.href.match('busy.org')) {
createBusyFeedPlusButton();
}
else {
setTimeout(check, 1000); // checkLoad again in a second
setTimeout(check, 1000); // addBeneficiariesButton again in a second
}
}
function createBusyFeedPlusButton() {
@@ -119,12 +119,14 @@ function StartFeedPlus() {
function GetFeed(author, perm) {
steem.api.getDiscussionsByFeed({
limit: LIMIT_PER_CALL,
tag: user,
start_author: author,
start_permlink: perm
}).then((result) => {feed_calls=feed_calls + 1;
}).then((result) => {
feed_calls=feed_calls + 1;
result.forEach(function (elt, i, array) {
if (feed_calls == 1 || (feed_calls != 1 && i != 0)) {
@@ -222,7 +224,7 @@ function getParameters()
case "hide":
return elt.resteem === "";
break;
//Show all except blacklist, also checkLoad rep
//Show all except blacklist, also addBeneficiariesButton rep
case "blacklist_radio":
return (elt.resteem === '' || !blacklist.split(' ').includes(elt.resteem));
View
@@ -42,7 +42,7 @@ function ResteemManager() {
first = false;
setTimeout(function () {
if ((website==='steemit'&&document.getElementsByClassName("UserProfile__buttons")[0].firstChild.firstChild.innerHTML === "Unfollow")||(website==='busy'&&$('.my-5')[0].innerHTML.match("Followed"))) {
if ((website==='steemit'&&$.inArray(document.getElementsByClassName("UserProfile__buttons")[0].firstChild.firstChild.innerHTML,["Unfollow","Se désabonner","Dejar de seguir","Отписаться","Non seguire&nbsp;più"] )>-1)||(website==='busy'&&$('.my-5')[0].innerHTML.match("Followed"))) {
var user = tab.split("@")[1];
if (resteem === "blacklist_radio") {
var add_blacklist;
Oops, something went wrong.

0 comments on commit dd75e59

Please sign in to comment.