Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Steemplus 2.17 : Tips #96

Merged
merged 4 commits into from
Jun 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Promise.all([steem.api.getDynamicGlobalPropertiesAsync(), steem.api.getCurrentMe
});
});

chrome.storage.local.get(['resteem_indicator','add_signature','author_popup_info','rewards_tab','wallet_history','wallet_history_memo_key','article_count','witnesses_tab','classification_user','board_reward','favorite_section','votePowerReserveRateLS','totalSteemLS','totalVestsLS','rewardBalanceLS','recentClaimsLS','steemPriceLS','post_floating_bottom_bar','post_floating_bottom_bar_size','last_post_url','smi_installed_remind_me', 'smi_installed_remind_me_time','md_editor_beautifier','blog_histogram','user_info_popover','gif_picker','boost_button','followers_table','vote_weight_slider','mentions_tab','search_bar','external_link_tab','vote_tab','steemit_more_info','post_votes_list', 'oneup','weight','del','transfers','acc_v','ben','drop','badge','username', 'nb_posts','resteem','sort','tag','list_tags','voted_check', 'rep_feed', 'rep_feed_check', 'classif','whitelist', 'blacklist','feedp','sessionToken','tokenExpire','market'], function (items) {
chrome.storage.local.get(['tip_user','resteem_indicator','add_signature','author_popup_info','rewards_tab','wallet_history','wallet_history_memo_key','article_count','witnesses_tab','classification_user','board_reward','favorite_section','votePowerReserveRateLS','totalSteemLS','totalVestsLS','rewardBalanceLS','recentClaimsLS','steemPriceLS','post_floating_bottom_bar','post_floating_bottom_bar_size','last_post_url','smi_installed_remind_me', 'smi_installed_remind_me_time','md_editor_beautifier','blog_histogram','user_info_popover','gif_picker','boost_button','followers_table','vote_weight_slider','mentions_tab','search_bar','external_link_tab','vote_tab','steemit_more_info','post_votes_list', 'oneup','weight','del','transfers','acc_v','ben','drop','badge','username', 'nb_posts','resteem','sort','tag','list_tags','voted_check', 'rep_feed', 'rep_feed_check', 'classif','whitelist', 'blacklist','feedp','sessionToken','tokenExpire','market'], function (items) {
var steemConnect=(items.sessionToken===undefined||items.tokenExpire===undefined)?{connect:false}:{connect:true,sessionToken:items.sessionToken,tokenExpire:items.tokenExpire};
chrome.runtime.sendMessage({ token:token, to: 'steemConnect', order: 'start',data:{steemConnect:steemConnect,steemit:steemit,busy:busy,utopian:utopian}} );
market=items.market==undefined?{SBDperSteem:0,priceSteem:0,priceSBD:0}:items.market;
Expand Down Expand Up @@ -251,6 +251,7 @@ function startOfflineFeatures(items, user, account)
const author_popup_info=(items.author_popup_info == undefined || items.author_popup_info=='show');
const add_signature=(items.add_signature == undefined || items.add_signature=='show');
const resteem_indicator=(items.resteem_indicator == undefined || items.resteem_indicator=='show');
const tip_user=(items.tip_user == undefined || items.tip_user=='show');


const smi_installed_remind_me=(items.smi_installed_remind_me == undefined || items.smi_installed_remind_me);
Expand Down Expand Up @@ -291,6 +292,8 @@ function startOfflineFeatures(items, user, account)
chrome.runtime.sendMessage({ token:token, to: 'add_signature', order: 'start',data:{user:user, steemit:steemit, busy:busy, utopian:utopian}});
if(resteem_indicator&&steemit)
chrome.runtime.sendMessage({ token:token, to: 'resteem_indicator', order: 'start',data:{}});
if(tip_user&&steemit)
chrome.runtime.sendMessage({ token:token, to: 'tip_user', order: 'start',data:{user:user}});


if (steemit_more_info) {
Expand Down Expand Up @@ -375,6 +378,8 @@ function startOfflineFeatures(items, user, account)
chrome.runtime.sendMessage({ token:token, to: 'add_signature', order: 'click',data:{user:user, steemit:steemit, busy:busy, utopian:utopian}});
if(resteem_indicator&&steemit)
chrome.runtime.sendMessage({ token:token, to: 'resteem_indicator', order: 'click',data:{}});
if(tip_user&&steemit)
chrome.runtime.sendMessage({ token:token, to: 'tip_user', order: 'click',data:{user:user}});


if($('.favorite-star').length > 0){
Expand Down
8 changes: 5 additions & 3 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

"name": "SteemPlus",
"description": "Lightweight toolbox for Steemit",
"version": "2.16.1",
"version": "2.17",
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'",
"browser_action": {
"default_icon": "src/img/logo.png",
Expand Down Expand Up @@ -97,7 +97,8 @@
"src/js/rewards_tab.js",
"src/js/author_popup_info.js",
"src/js/add_signature.js",
"src/js/resteem_indicator.js"],
"src/js/resteem_indicator.js",
"src/js/tip_user.js"],

"css":["vendor/unslider/unslider.css","vendor/font-awesome.min.css","vendor/unslider/unslider-dots.css","vendor/bootstrap.css","vendor/bootstrap-grid.css","vendor/btn.css","vendor/datatables.min.css","vendor/justifiedGallery.min.css","vendor/toastr.min.css",
"src/css/delegate.css",
Expand All @@ -121,7 +122,8 @@
"src/css/rewards_tab.css",
"src/css/author_popup_info.css",
"src/css/add_signature.css",
"src/css/resteem_indicator.css"],
"src/css/resteem_indicator.css",
"src/css/tip_user.css"],
"run_at": "document_idle"
}
]
Expand Down
10 changes: 10 additions & 0 deletions popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,16 @@ <h3>Login</h3>
<p class="option-description">Display who resteemed a post></a></p>
</div>

<div class="sp_option">
<label class="switch">
<input type="checkbox" name="tip_user" id="tip_user">
<span class="slider2 round"></span>
</label>
<p class="option-title">Tips</p>
<div class="platform-indicators"><img class="platform-indicator-logo" src="src/img/platform-logos/steemit.png"></div>
<p class="option-description">Send a tip to any user from the user popup.</a></p>
</div>

<div class="sp_option_list_title">
<label class="switch">
<input type="checkbox" name="steemit_more_info" id="steemit_more_info">
Expand Down
10 changes: 9 additions & 1 deletion popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var isConnectedToSteemConnect=null;

$('#shortcuts, .switch-text').hide();
// Get local parameters stored using Chrome Storage API
chrome.storage.local.get(['resteem_indicator','add_signature','author_popup_info','rewards_tab','wallet_history','article_count','witnesses_tab','classification_user','board_reward','favorite_section','post_floating_bottom_bar','md_editor_beautifier','blog_histogram','user_info_popover','gif_picker','boost_button','followers_table','vote_weight_slider','mentions_tab','search_bar','external_link_tab','vote_tab','steemit_more_info','post_votes_list','onboarding','oneup','sessionToken','tokenExpire','weight','resteem','blacklist','whitelist','reputation','rep','badge','del','ben','feedp','drop','acc_v','transfers'], function (items) {
chrome.storage.local.get(['tip_user','resteem_indicator','add_signature','author_popup_info','rewards_tab','wallet_history','article_count','witnesses_tab','classification_user','board_reward','favorite_section','post_floating_bottom_bar','md_editor_beautifier','blog_histogram','user_info_popover','gif_picker','boost_button','followers_table','vote_weight_slider','mentions_tab','search_bar','external_link_tab','vote_tab','steemit_more_info','post_votes_list','onboarding','oneup','sessionToken','tokenExpire','weight','resteem','blacklist','whitelist','reputation','rep','badge','del','ben','feedp','drop','acc_v','transfers'], function (items) {
var steemConnect=(items.sessionToken===undefined||items.tokenExpire===undefined||items.tokenExpire<Date.now())?{connect:false}:{connect:true,sessionToken:items.sessionToken,tokenExpire:items.tokenExpire};
isConnectedToSteemConnect = steemConnect.connect;
// Connected
Expand Down Expand Up @@ -98,6 +98,7 @@ chrome.storage.local.get(['resteem_indicator','add_signature','author_popup_info
author_popup_info=items.author_popup_info==undefined?'show':items.author_popup_info;
add_signature=items.add_signature==undefined?'show':items.add_signature;
resteem_indicator=items.resteem_indicator==undefined?'show':items.resteem_indicator;
tip_user=items.tip_user==undefined?'show':items.tip_user;

// Steemit more info
steemit_more_info=items.steemit_more_info==undefined?'show':items.steemit_more_info;
Expand Down Expand Up @@ -146,6 +147,7 @@ chrome.storage.local.get(['resteem_indicator','add_signature','author_popup_info
$('input[name=author_popup_info]').prop('checked',author_popup_info=='show');
$('input[name=add_signature]').prop('checked',add_signature=='show');
$('input[name=resteem_indicator]').prop('checked',resteem_indicator=='show');
$('input[name=tip_user]').prop('checked',tip_user=='show');

// Steemit more info
$('input[name=steemit_more_info]').prop('checked',steemit_more_info=='show');
Expand Down Expand Up @@ -471,6 +473,12 @@ $(document).on("change","input[name=resteem_indicator]",function(){
});
});

$(document).on("change","input[name=tip_user]",function(){
chrome.storage.local.set({
tip_user:$("input[name=tip_user]").prop('checked')?'show':'hide'
});
});

$(document).on("change","input[name=steemit_more_info]",function(){

chrome.storage.local.set({
Expand Down
40 changes: 40 additions & 0 deletions src/css/tip_user.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
.tip-button
{
height: 1.5rem;
line-height: 1;
padding-left: 0.25rem;
padding-right: 0.25rem;
margin-left: 0.25rem;
margin-right: 0.25rem;
}

.input-value-tip
{
height: 1.5rem !important;
width: 20%;
margin-right: 0;
margin-left: 0.25rem !important;
border-radius: 3px 0px 0px 3px !important;
}

.input-group > :first-child
{
border-radius: 3px !important;
}

.input-group > :last-child
{
border-radius: 0px 3px 3px 0px !important;
margin-left: 0;

}

.div-tip
{
margin-top: 1rem;
}

.Author__container, .Author__dropdown
{
width: 320px !important;
}
3 changes: 1 addition & 2 deletions src/js/author_popup_info.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function startAuthorPopupInfo()
else
{
// Start feature
$('.ptc').unbind('click').click(function(){
$('.ptc').click(function(){
var userAuthorPopupInfo = $(this)[0].pathname.replace('/@', '');
$('.Author__dropdown').append('<hr><div class="author-popup-message"></div>');

Expand Down Expand Up @@ -91,7 +91,6 @@ function startAuthorPopupInfo()
// Else check is user is a witness
steem.api.getWitnessByAccount(myUsernameAuthorPopupInfo, function(err, res){
// if he is display a message saying that author didn't voted for him
console.log(res);
if(res!=='')
{
$('.author-popup-message').append('<span class="author-popup-witness">Didn\'t vote for you as a witness</span><br>');
Expand Down
128 changes: 128 additions & 0 deletions src/js/tip_user.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@


var token_tip_user=null;
var retryUserTip=0;
var myUsernameTip=null;

// Listener for messages coming from main.js
chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {

if(request.to==='tip_user'&&request.order==='start'&&token_tip_user==null)
{
retryUserTip = 0;
token_tip_user=request.token;
myUsernameTip=request.data.user;
startTipUser();
}
else if(request.to==='tip_user'&&request.order==='click'&&token_tip_user===request.token){
retryUserTip = 0;
myUsernameTip=request.data.user;
startTipUser();
}
});

// Function used to check url and start feature
// No parameters
function startTipUser()
{
// Check url of the page. Need to be on a post to start the function
if(regexPostSteemit.test(window.location.href)&&retryUserTip<20)
{
if($('.ptc').length===0)
{
// Looking for the right html element. If can't find it retry later. Maximum 20 seconds
retryUserTip++;
setTimeout(startTipUser, 1000);
}
else
{
// Start feature
$('.ptc').click(function(){
var userAuthorPopupInfoTip = $(this)[0].pathname.replace('/@', '');

// Create div
var tipDiv = $('<div class="input-group div-hidden div-tip" style="margin-bottom: 5px;">\
<input type="button" value="0.5$" name="0.5" class="btn btn-primary btn-sm tip-button">\
<input type="button" value="1$" name="1" class="btn btn-primary btn-sm tip-button">\
<input type="button" value="2$" name="2" class="btn btn-primary btn-sm tip-button">\
<input type="button" value="5$" name="5" class="btn btn-primary btn-sm tip-button">\
<input type="button" value="10$" name="10" class="btn btn-primary btn-sm tip-button">\
<input class="input-value-tip" id="value-tip" type="text" placeholder="..." name="tip" value="" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" autofocus="">\
<input type="button" value="$" name="other" class="btn btn-primary btn-sm tip-button">\
</div>');

$('.Author__bio').before(tipDiv);
$(tipDiv).hide();
$('label.button.slim.hollow.secondary').parent().append('<label id="hide-show-tip-btn" class="button slim hollow secondary" title="Send a tip">Tip</label>')

// Click listener on tip button
$('#hide-show-tip-btn').click(function(){
if($(tipDiv).hasClass('div-hidden'))
{
$(tipDiv).addClass('div-shown');
$(tipDiv).removeClass('div-hidden');
$(tipDiv).show('slow');
}
else
{
$(tipDiv).addClass('div-hidden');
$(tipDiv).removeClass('div-shown');
$(tipDiv).hide('slow');
}
});

// Listener on tip buttons
$('.tip-button').click(function(){
console.log($(this));
var amountTip=0;
if($(this).attr('name')==='other')
{
if($('.input-value-tip')[0].value==='')
{
// Set config of toastr
toastr.options = {
"closeButton": false,
"debug": false,
"newestOnTop": false,
"progressBar": false,
"positionClass": "toast-bottom-center",
"preventDuplicates": false,
"onclick": null,
"showDuration": "300",
"hideDuration": "1000",
"timeOut": 2000,
"extendedTimeOut": 0,
"showEasing": "swing",
"hideEasing": "linear",
"showMethod": "fadeIn",
"hideMethod": "fadeOut",
"tapToDismiss": false
};
// Save signature in local storage and display a toastr to inform users
toastr.error('You need to add a value!', "Message from SteemPlus");
return;
}
else
amountTip = $('.input-value-tip')[0].value;
}
else
amountTip = $(this).attr('name');


var memoTip = 'Tip sent from ' + myUsernameTip + ' to ' + userAuthorPopupInfoTip + ' using steem-plus tipping system! (https://steemit.com/@steem-plus)';
var urlTip = 'https://v2.steemconnect.com/sign/transfer?from='+myUsernameTip+'&to='+userAuthorPopupInfoTip+'&amount='+amountTip+'%20SBD&memo='+ memoTip;
var win = window.open(urlTip, '_blank');
if (win) {
//Browser has allowed it to be opened
win.focus();
} else {
//Browser has blocked it
alert('Please allow popups for this website');
}
});

});
}
}

}