Skip to content

Commit 19993df

Browse files
eatsleepcoderepeat-gleatsleepcoderepeat
and
eatsleepcoderepeat
authored
Added all.user.js as a master script that loads all other scripts in the repository, offering a more convenient install option for users (#21)
* Fixed button name * Added master script that loads all other scripts for a more convenient user experience * Version bump * Updated to use template literals instead of concatenation * Version bump * Updated authors * Added error handling * Added information about the master script to the readme * Added disclaimer/note about using the master script * Added warning icon * Elaborated on warning in script description, updated description in script * Added emphasis to warning * Elaborated on warning * Script title updated * Warning update * Updated warning * Added missing target-restore script, updated description * Added Tampermonkey links * Added info about Tampermonkey * Adjusted readme flow * Removed locale from Firefox extension URL * Added additional Tampermonkey links * Updated link * Added info on how to switch chart source * Added emphasis to help text * Fixed capitalization * Clarified chart source instructions * Made chart source instruction text more concise * Adjusted author order * Update README.md * Synced indentation level with other scripts * Synced indentation level with other scripts * Simplified array concatenation * Removed extra comma from target concatenation * Pointed endpoints at production, updated attribution * Version bump * Version bump * Updated description text for all.user.js Co-authored-by: eatsleepcoderepeat <[email protected]>
1 parent e79f650 commit 19993df

11 files changed

+661
-561
lines changed

README.md

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ You are responsible for the code you run on your own computer. By downloading an
2727

2828
Cryptohopper may change their website at any moment, causing one or all of these scripts to cease functioning.
2929

30+
## all.user.js
31+
32+
> By [@eatsleepcoderepeat-gl](https://github.com/eatsleepcoderepeat-gl) (Xerahn on Discord)
33+
34+
* The one script to rule them all. This is a master script, provided for user convenience, which will load all other scripts available at the time of installation. This will also keep all other loaded scripts from this project up to date as well and if auto update is enabled, will add any new features (scripts) automatically. ⚠️ *If using this, there's no need to manually install individual scripts; any other installed scripts from this project should be uninstalled prior to installing this script.*
35+
3036
## coin-watchlist.user.js
3137

3238
* Allows you to track a coin by icon/color across all your hoppers. Highlight the losers or mark positions that are heavily dollar cost averaged to more easily visually identify them in your dashboard or mark coins that are part of a custom config pool.
@@ -58,7 +64,7 @@ Cryptohopper may change their website at any moment, causing one or all of these
5864
:-:|:-:
5965
![](images/chart-mods-light.png) | ![](images/chart-mods-dark.png)
6066

61-
> Note: Some users are served the chart on `chart/chart_tradingview.php` and this script will not work if your charts are loaded from there. It will only work on the `chart/chart.php` url.
67+
> Note: Some users are served the chart on `chart/chart_tradingview.php` and this script will not work if your charts are loaded from there. It will only work on the `chart/chart.php` url. *Enable this feature by switching to the default chart souce: [Profile](https://www.cryptohopper.com/edit-profile) > Settings > Chart source, and select the default option.*
6268
6369
## position-targets.user.js
6470

@@ -105,7 +111,7 @@ Cryptohopper may change their website at any moment, causing one or all of these
105111

106112
# Installation:
107113

108-
1. Select a the user script you want from this repository.
114+
1. Select a user script you want from this repository.
109115
1. Read through the script and familiarize yourself with the code. Make sure you understand what it does before you install it!
110116
1. Click the "Raw" button and your browser extension should ask you to install it.
111117
1. Navigate to your Cryptohopper dashboard.
@@ -115,7 +121,26 @@ Cryptohopper may change their website at any moment, causing one or all of these
115121

116122
### Quick install links:
117123

118-
> If you already have TamperMonkey installed and know what you're dong:
124+
#### Tampermonkey:
125+
126+
> A userscript browser extension is needed in order to install the below scripts, such as [Tampermonkey](https://www.tampermonkey.net/):
127+
128+
* [`Chrome`](https://chrome.google.com/webstore/detail/tampermonkey/dhdgffkkebhmkfjojejmpbldmpobfkfo)
129+
* [`Firefox`](https://addons.mozilla.org/firefox/addon/tampermonkey/)
130+
* [`Safari 12+`](https://apps.apple.com/app/apple-store/id1482490089?pt=117945903&ct=tm.net)
131+
* [`Safari 6-11`](https://safari.tampermonkey.net/tampermonkey.safariextz)
132+
* [`Opera Next`](https://addons.opera.com/en/extensions/details/tampermonkey-beta/)
133+
* [`Dolphin Browser`](https://play.google.com/store/apps/details?id=net.tampermonkey.dolphin)
134+
* [`UC Browser`](https://play.google.com/store/apps/details?id=net.tampermonkey.uc)
135+
* [`Edge`](https://microsoftedge.microsoft.com/addons/detail/tampermonkey/iikmkjmpaadaobahmlepeloendndfphd)
136+
137+
> If you already have Tampermonkey installed and know what you're dong:
138+
139+
#### All in one master script:
140+
141+
* [`all.user.js`](https://github.com/markrickert/cryptohopper-dashboard-watchlist/raw/main/all.user.js) ⚠️ *No need to install other scripts if using this one. Please uninstall all below scripts prior to installing this.*
142+
143+
#### Individual scripts:
119144

120145
* [`coin-watchlist.user.js`](https://github.com/markrickert/cryptohopper-dashboard-watchlist/raw/main/coin-watchlist.user.js)
121146
* [`absolute-value.user.js`](https://github.com/markrickert/cryptohopper-dashboard-watchlist/raw/main/absolute-value.user.js)

absolute-value.user.js

Lines changed: 82 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// ==UserScript==
22
// @name Cryptohopper Absolute Values
33
// @namespace https://github.com/markrickert/cryptohopper-dashboard-watchlist
4-
// @version 0.2
4+
// @version 0.3
55
// @description Adds absolute value for your open positions after the percentage change.
66
// @author @eatsleepcoderepeat-gl, @markrickert
77
// @homepage https://github.com/markrickert/cryptohopper-dashboard-watchlist
@@ -11,90 +11,96 @@
1111
// @grant GM_addStyle
1212
// ==/UserScript==
1313

14-
(function () {
15-
"use strict";
14+
try {
15+
// Only run this code on the intended page(s) (useful when @required in a parent script)
16+
if(['/dashboard'].includes(window.location.pathname)) (function () {
17+
"use strict";
1618

17-
function addStyles() {
18-
GM_addStyle(`
19-
span[class*="rate_"]>span {
20-
margin-left: 0.5em;
21-
}
22-
`);
23-
}
19+
function addStyles() {
20+
GM_addStyle(`
21+
span[class*="rate_"]>span {
22+
margin-left: 0.5em;
23+
}
24+
`);
25+
}
2426

25-
// Add absolute value to the Result column
26-
function addAbsoluteResult(targets) {
27-
// get unique currencyPairs:
28-
var currencyTicketUpdatePairs = Object.keys(targets).map((cv, i) =>
29-
// Some coin pairs come back as 1INCH/USDT instead of 1INCHUSDT
30-
cv.replace("/", "_")
31-
);
32-
var spanSelectors = currencyTicketUpdatePairs.map((currentValue, index) => {
33-
return `span.rate_${currentValue}`;
34-
});
27+
// Add absolute value to the Result column
28+
function addAbsoluteResult(targets) {
29+
// get unique currencyPairs:
30+
var currencyTicketUpdatePairs = Object.keys(targets).map((cv, i) =>
31+
// Some coin pairs come back as 1INCH/USDT instead of 1INCHUSDT
32+
cv.replace("/", "_")
33+
);
34+
var spanSelectors = currencyTicketUpdatePairs.map((currentValue, index) => {
35+
return `span.rate_${currentValue}`;
36+
});
3537

36-
spanSelectors.forEach((currencyPairSelector, i) => {
37-
$(`${currencyPairSelector}`).each(function () {
38-
var el = $(this); // Turn it into a jquery object
39-
var tx = el.text().split("(")[0]; // gets the percentage changed text
40-
var change = tx.trim().replace("%", ""); // gets the raw number without %
41-
let td = $(this).closest("td").prev(); // We think the previous td is the cost.
42-
// Setup vars
43-
let cost = false;
44-
var thText;
38+
spanSelectors.forEach((currencyPairSelector, i) => {
39+
$(`${currencyPairSelector}`).each(function () {
40+
var el = $(this); // Turn it into a jquery object
41+
var tx = el.text().split("(")[0]; // gets the percentage changed text
42+
var change = tx.trim().replace("%", ""); // gets the raw number without %
43+
let td = $(this).closest("td").prev(); // We think the previous td is the cost.
44+
// Setup vars
45+
let cost = false;
46+
var thText;
4547

46-
// Try to find the cost of the position by searching the
47-
// table headers for the word "Cost".
48-
while (cost === false) {
49-
thText = td
50-
.closest("tbody")
51-
.prev("thead")
52-
.find("> tr > th:eq(" + td.index() + ")");
53-
if (thText.length) {
54-
// If we found a header element
55-
if (thText.text().toLowerCase() === "cost") {
56-
// We know the current <td> contains the cost
57-
cost = td.text().trim();
48+
// Try to find the cost of the position by searching the
49+
// table headers for the word "Cost".
50+
while (cost === false) {
51+
thText = td
52+
.closest("tbody")
53+
.prev("thead")
54+
.find("> tr > th:eq(" + td.index() + ")");
55+
if (thText.length) {
56+
// If we found a header element
57+
if (thText.text().toLowerCase() === "cost") {
58+
// We know the current <td> contains the cost
59+
cost = td.text().trim();
60+
} else {
61+
// Go back one <td> and look at the header again.
62+
td = td.prev();
63+
}
5864
} else {
59-
// Go back one <td> and look at the header again.
60-
td = td.prev();
65+
break;
6166
}
62-
} else {
63-
break;
6467
}
65-
}
6668

67-
if (cost) {
68-
try {
69-
// Update the span with the change
70-
const difference = ((change / 100) * cost).toFixed(2);
71-
const elHTML = el.text().split("(")[0];
72-
el.html(elHTML + "<span>(" + difference + ")</span>");
73-
} catch (e) {
74-
console.log(
75-
"absolute-value.user.js - error setting absolute change value."
76-
);
69+
if (cost) {
70+
try {
71+
// Update the span with the change
72+
const difference = ((change / 100) * cost).toFixed(2);
73+
const elHTML = el.text().split("(")[0];
74+
el.html(elHTML + "<span>(" + difference + ")</span>");
75+
} catch (e) {
76+
console.log(
77+
"absolute-value.user.js - error setting absolute change value."
78+
);
79+
}
7780
}
78-
}
81+
});
7982
});
80-
});
81-
}
83+
}
8284

83-
// This function listens for network requests and intercepts the target list to turn their icon on and off.
84-
function watchTicker() {
85-
setTimeout(() => {
86-
socket.on("message", function (a) {
87-
var parsed = JSON.parse(a);
88-
if ("ticker" == parsed.type) {
89-
// console.log("result", parsed.result)
90-
addAbsoluteResult(parsed.result);
91-
}
92-
});
93-
}, 1000); // delay accessing the socket variable so we know it's initialized.
94-
}
85+
// This function listens for network requests and intercepts the target list to turn their icon on and off.
86+
function watchTicker() {
87+
setTimeout(() => {
88+
socket.on("message", function (a) {
89+
var parsed = JSON.parse(a);
90+
if ("ticker" == parsed.type) {
91+
// console.log("result", parsed.result)
92+
addAbsoluteResult(parsed.result);
93+
}
94+
});
95+
}, 1000); // delay accessing the socket variable so we know it's initialized.
96+
}
9597

96-
jQuery(() => {
97-
addStyles();
98-
watchTicker();
99-
});
100-
})();
98+
jQuery(() => {
99+
addStyles();
100+
watchTicker();
101+
});
102+
})();
103+
}
104+
catch(err) {
105+
console.log(`Error in script absolute-value.user.js: ${err.name}: ${err.message}`);
106+
}

all.user.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// ==UserScript==
2+
// @name Cryptohopper MASTER SCRIPT
3+
// @namespace https://github.com/markrickert/cryptohopper-dashboard-watchlist
4+
// @version 0.1
5+
// @description The one script to rule them all. This is a master script, provided for user convenience, which will load all other scripts available at the time of installation. This will also keep all other loaded scripts from this project up to date as well and if auto update is enabled, will add any new features (scripts) automatically. If using this, there's no need to manually install individual scripts; any other installed scripts from this project should be uninstalled prior to installing this script.
6+
// @author @markrickert, @eatsleepcoderepeat-gl, @henrygarle
7+
// @homepage https://github.com/markrickert/cryptohopper-dashboard-watchlist
8+
// @updateURL https://github.com/markrickert/cryptohopper-dashboard-watchlist/raw/main/all.user.js
9+
// @match https://www.cryptohopper.com/*
10+
// @icon https://www.google.com/s2/favicons?domain=cryptohopper.com
11+
// @require https://github.com/markrickert/cryptohopper-dashboard-watchlist/raw/main/coin-watchlist.user.js
12+
// @require https://github.com/markrickert/cryptohopper-dashboard-watchlist/raw/main/absolute-value.user.js
13+
// @require https://github.com/markrickert/cryptohopper-dashboard-watchlist/raw/main/chart-mods.user.js
14+
// @require https://github.com/markrickert/cryptohopper-dashboard-watchlist/raw/main/position-targets.user.js
15+
// @require https://github.com/markrickert/cryptohopper-dashboard-watchlist/raw/main/target-restore.user.js
16+
// @require https://github.com/markrickert/cryptohopper-dashboard-watchlist/raw/main/remove-hoppie.user.js
17+
// @require https://github.com/markrickert/cryptohopper-dashboard-watchlist/raw/main/stay-level-headed.user.js
18+
// @require https://github.com/markrickert/cryptohopper-dashboard-watchlist/raw/main/multi-select.user.js
19+
// @require https://github.com/markrickert/cryptohopper-dashboard-watchlist/raw/main/export-saved-trade-history.user.js
20+
// @grant GM_addStyle
21+
// @grant GM_getValue
22+
// @grant GM_listValues
23+
// @grant GM_setValue
24+
// @grant GM_deleteValue
25+
26+
// ==/UserScript==

chart-mods.user.js

Lines changed: 41 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// ==UserScript==
22
// @name Cryptohopper Tradingview Chart Mods
33
// @namespace https://github.com/markrickert/cryptohopper-dashboard-watchlist
4-
// @version 0.1
4+
// @version 0.2
55
// @description Adds a few extra things to the Tradingview charts like average buy rate and indicator on your last buy.
66
// @author @markrickert
77
// @homepage https://github.com/markrickert/cryptohopper-dashboard-watchlist
@@ -10,42 +10,48 @@
1010
// @icon https://www.google.com/s2/favicons?domain=cryptohopper.com
1111
// ==/UserScript==
1212

13-
(function () {
14-
"use strict";
13+
try {
14+
// Only run this code on the intended page(s) (useful when @required in a parent script)
15+
if(['/chart/chart.php'].includes(window.location.pathname)) (function () {
16+
"use strict";
1517

16-
const buyRate = parseFloat(getParameterByName("buy_rate"));
17-
const buyTime = parseInt(getParameterByName("buy_time"));
18-
const tpRate = getParameterByName("tp_rate");
19-
const slRate = getParameterByName("sl_rate");
18+
const buyRate = parseFloat(getParameterByName("buy_rate"));
19+
const buyTime = parseInt(getParameterByName("buy_time"));
20+
const tpRate = getParameterByName("tp_rate");
21+
const slRate = getParameterByName("sl_rate");
2022

21-
function mod_createBuyMoment(buyRate, buyTime) {
22-
widget
23-
.chart()
24-
.createExecutionShape()
25-
.setText("BUY")
26-
.setTextColor("#29c79e")
27-
.setArrowColor("#29c79e")
28-
.setArrowSpacing(5)
29-
.setArrowHeight(10)
30-
.setDirection("buy")
31-
.setTime(buyTime)
32-
.setPrice(parseFloat(buyRate));
33-
}
23+
function mod_createBuyMoment(buyRate, buyTime) {
24+
widget
25+
.chart()
26+
.createExecutionShape()
27+
.setText("BUY")
28+
.setTextColor("#29c79e")
29+
.setArrowColor("#29c79e")
30+
.setArrowSpacing(5)
31+
.setArrowHeight(10)
32+
.setDirection("buy")
33+
.setTime(buyTime)
34+
.setPrice(parseFloat(buyRate));
35+
}
3436

35-
function mod_createPositionLine(buyRate, tpRate, slRate) {
36-
createPositionLine("Avg Cost", buyRate, 0, tpRate, slRate);
37-
}
37+
function mod_createPositionLine(buyRate, tpRate, slRate) {
38+
createPositionLine("Avg Cost", buyRate, 0, tpRate, slRate);
39+
}
3840

39-
function initChartMods() {
40-
widget.onChartReady(function () {
41-
if (buyRate && widget) {
42-
mod_createPositionLine(buyRate, tpRate, slRate);
43-
mod_createBuyMoment(buyRate, buyTime);
44-
}
45-
});
46-
}
41+
function initChartMods() {
42+
widget.onChartReady(function () {
43+
if (buyRate && widget) {
44+
mod_createPositionLine(buyRate, tpRate, slRate);
45+
mod_createBuyMoment(buyRate, buyTime);
46+
}
47+
});
48+
}
4749

48-
window.onload = function (e) {
49-
initChartMods();
50-
};
51-
})();
50+
window.onload = function (e) {
51+
initChartMods();
52+
};
53+
})();
54+
}
55+
catch(err) {
56+
console.log(`Error in script chart-mods.user.js: ${err.name}: ${err.message}`);
57+
}

0 commit comments

Comments
 (0)