Skip to content

Commit caeb67e

Browse files
committed
Update files to conform to linter.
1 parent d42206e commit caeb67e

10 files changed

+610
-529
lines changed

absolute-value.user.js

+78-74
Original file line numberDiff line numberDiff line change
@@ -13,94 +13,98 @@
1313

1414
try {
1515
// 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";
16+
if (["/dashboard"].includes(window.location.pathname))
17+
(function () {
18+
"use strict";
1819

19-
function addStyles() {
20-
GM_addStyle(`
20+
function addStyles() {
21+
GM_addStyle(`
2122
span[class*="rate_"]>span {
2223
margin-left: 0.5em;
2324
}
2425
`);
25-
}
26+
}
2627

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

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

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();
51+
// Try to find the cost of the position by searching the
52+
// table headers for the word "Cost".
53+
while (cost === false) {
54+
thText = td
55+
.closest("tbody")
56+
.prev("thead")
57+
.find("> tr > th:eq(" + td.index() + ")");
58+
if (thText.length) {
59+
// If we found a header element
60+
if (thText.text().toLowerCase() === "cost") {
61+
// We know the current <td> contains the cost
62+
cost = td.text().trim();
63+
} else {
64+
// Go back one <td> and look at the header again.
65+
td = td.prev();
66+
}
6067
} else {
61-
// Go back one <td> and look at the header again.
62-
td = td.prev();
68+
break;
6369
}
64-
} else {
65-
break;
6670
}
67-
}
6871

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-
);
72+
if (cost) {
73+
try {
74+
// Update the span with the change
75+
const difference = ((change / 100) * cost).toFixed(2);
76+
const elHTML = el.text().split("(")[0];
77+
el.html(elHTML + "<span>(" + difference + ")</span>");
78+
} catch (e) {
79+
console.log(
80+
"absolute-value.user.js - error setting absolute change value."
81+
);
82+
}
7983
}
80-
}
84+
});
8185
});
82-
});
83-
}
86+
}
8487

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

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}`);
101+
jQuery(() => {
102+
addStyles();
103+
watchTicker();
104+
});
105+
})();
106+
} catch (err) {
107+
console.log(
108+
`Error in script absolute-value.user.js: ${err.name}: ${err.message}`
109+
);
106110
}

all.user.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@
2323
// @grant GM_setValue
2424
// @grant GM_deleteValue
2525

26-
// ==/UserScript==
26+
// ==/UserScript==

chart-mods.user.js

+39-37
Original file line numberDiff line numberDiff line change
@@ -12,46 +12,48 @@
1212

1313
try {
1414
// 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";
15+
if (["/chart/chart.php"].includes(window.location.pathname))
16+
(function () {
17+
"use strict";
1718

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");
19+
const buyRate = parseFloat(getParameterByName("buy_rate"));
20+
const buyTime = parseInt(getParameterByName("buy_time"));
21+
const tpRate = getParameterByName("tp_rate");
22+
const slRate = getParameterByName("sl_rate");
2223

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-
}
24+
function mod_createBuyMoment(buyRate, buyTime) {
25+
widget
26+
.chart()
27+
.createExecutionShape()
28+
.setText("BUY")
29+
.setTextColor("#29c79e")
30+
.setArrowColor("#29c79e")
31+
.setArrowSpacing(5)
32+
.setArrowHeight(10)
33+
.setDirection("buy")
34+
.setTime(buyTime)
35+
.setPrice(parseFloat(buyRate));
36+
}
3637

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

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-
}
42+
function initChartMods() {
43+
widget.onChartReady(function () {
44+
if (buyRate && widget) {
45+
mod_createPositionLine(buyRate, tpRate, slRate);
46+
mod_createBuyMoment(buyRate, buyTime);
47+
}
48+
});
49+
}
4950

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}`);
51+
window.onload = function (e) {
52+
initChartMods();
53+
};
54+
})();
55+
} catch (err) {
56+
console.log(
57+
`Error in script chart-mods.user.js: ${err.name}: ${err.message}`
58+
);
5759
}

0 commit comments

Comments
 (0)