Skip to content

Commit bd01eb5

Browse files
eatsleepcoderepeat-gleatsleepcoderepeat
andauthored
Fixed button name (#16)
* Fixed button name * Version bump * Updated to use template literals instead of concatenation Co-authored-by: eatsleepcoderepeat <[email protected]>
1 parent 74d5d7c commit bd01eb5

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

export-saved-trade-history.user.js

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// ==UserScript==
22
// @name Cryptohopper Export Saved Trade History
33
// @namespace https://github.com/markrickert/cryptohopper-dashboard-watchlist
4-
// @version 0.1
4+
// @version 0.2
55
// @description Adds single-click export functionality to the trade history page using the saved settings (after saving at least once), and allows for saving and loading export settings. The author of this script finds it useful to set the to part of the date range to sometime in the future when using this functionality, such as 01/01/2030 12:00 AM.
66
// @author @eatsleepcoderepeat-gl
77
// @homepage https://github.com/markrickert/cryptohopper-dashboard-watchlist
@@ -38,20 +38,22 @@ if(['/trade-history'].includes(window.location.pathname)) (function () {
3838

3939
// This function sets our CSS
4040
function setStyles() {
41-
GM_addStyle(
42-
'button' + EXPORT_BUTTON_NAME +
43-
',button' + SAVE_BUTTON_NAME +
44-
'{ margin-right: 3px; }' +
45-
'button' + LOAD_BUTTON_NAME +
46-
'{ margin-right: 2px; }'
47-
);
41+
GM_addStyle(`
42+
button${EXPORT_BUTTON_NAME},
43+
button${SAVE_BUTTON_NAME} {
44+
margin-right: 3px;
45+
}
46+
button${LOAD_BUTTON_NAME} {
47+
margin-right: 2px;
48+
}
49+
`);
4850
}
4951

5052
// This function adds the Export Saved button and handles click events
5153
function exportButtonHandler() {
5254
if(!$(EXPORT_BUTTON_NAME).length && GM_getValue(EXPORT_KEY,false) !== false) {
5355
// Add the Export Saved button
54-
$(`button[onclick="jQuery('#exportDiv').toggle()"]`).before('<button id="' + EXPORT_BUTTON_NAME.replace('#','') + '" type="button" class="' + BUTTON_PRIMARY_CLASS + '"><i class="fa fa-download m-r-5"></i> Export Saved</button>');
56+
$(`button[onclick="jQuery('#exportDiv').toggle()"]`).before(`<button type="button" id="${EXPORT_BUTTON_NAME.replace('#','')}" class="${BUTTON_PRIMARY_CLASS}"><i class="fa fa-download m-r-5"></i> Export Saved</button>`);
5557

5658
// Handle clicks of the Export Saved button
5759
$(EXPORT_BUTTON_NAME).on('click',function() {
@@ -67,7 +69,7 @@ if(['/trade-history'].includes(window.location.pathname)) (function () {
6769
// This function saves the current settings when exporting
6870
function saveSettingsButtonHandler() {
6971
// Add the Save Settings button
70-
$('button[onclick="startExport()"]').before('<button id="' + SAVE_BUTTON_NAME.replace('#','') + '" type="button" class="' + BUTTON_PRIMARY_CLASS + '">Save Settings</button>');
72+
$('button[onclick="startExport()"]').before(`<button type="button" id="${SAVE_BUTTON_NAME.replace('#','')}" class="${BUTTON_PRIMARY_CLASS}">Save Settings</button>`);
7173

7274
// Handle clicks of the Save Settings button
7375
$(SAVE_BUTTON_NAME).on('click',function() {
@@ -79,7 +81,7 @@ if(['/trade-history'].includes(window.location.pathname)) (function () {
7981
// Save these values for future use
8082
GM_setValue(EXPORT_KEY,JSON.stringify({'format':format,'buys':buys,'sells':sells,'daterange':daterange}));
8183

82-
// If this is the first time saving, add the Export Saved button
84+
// If this is the first time saving, add the Export Saved and Load Settings buttons
8385
if(!buttonsAdded) {
8486
exportButtonHandler();
8587
loadSettingsButtonHandler();
@@ -90,10 +92,10 @@ if(['/trade-history'].includes(window.location.pathname)) (function () {
9092
// This function loads the currently saved settings
9193
function loadSettingsButtonHandler() {
9294
if(!$(LOAD_BUTTON_NAME).length && GM_getValue(EXPORT_KEY,false) !== false) {
93-
// Add the Load Saved button
94-
$(SAVE_BUTTON_NAME).before('<button id="' + LOAD_BUTTON_NAME.replace('#','') + '" type="button" class="' + BUTTON_SECONDARY_CLASS + '">Load Saved</button>');
95+
// Add the Load Settings button
96+
$(SAVE_BUTTON_NAME).before(`<button type="button" id="${LOAD_BUTTON_NAME.replace('#','')}" class="${BUTTON_SECONDARY_CLASS}">Load Settings</button>`);
9597

96-
// Handle clicks of the Load Saved button
98+
// Handle clicks of the Load Settings button
9799
$(LOAD_BUTTON_NAME).on('click',loadSavedSettings);
98100

99101
buttonsAdded = true;

0 commit comments

Comments
 (0)