-
Notifications
You must be signed in to change notification settings - Fork 62
/
Copy pathbetterNSE.user.js
100 lines (85 loc) · 2.93 KB
/
betterNSE.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
// ==UserScript==
// @name betterNSE
// @namespace https://github.com/amit0rana/betterNSE
// @version 0.02
// @description Introduces small features on top of nse website
// @author Amit
// @match https://www.nseindia.com/*
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_addStyle
// @grant GM_registerMenuCommand
// @require https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js
// @require https://raw.githubusercontent.com/amit0rana/MonkeyConfig/master/monkeyconfig.js
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js
// @downloadURL https://github.com/amit0rana/betterOptionsTrading/raw/master/betterNSE.user.js
// @updateURL https://github.com/amit0rana/betterOptionsTrading/raw/master/betterNSE.meta.js
// ==/UserScript==
const formatter = Intl.NumberFormat('en-IN');
var isMultiply = true;
function changeButtonName() {
var btn = $('#addLot');
if (isMultiply) {
$(btn).val('Divide 75');
isMultiply = false;
} else {
isMultiply = true;
$(btn).val('Multiply 75');
}
}
function getNumber(n) {
if (isMultiply) {
return formatter.format(n*75);
} else {
return formatter.format(n/75);
}
}
var i = document.createElement("INPUT");
i.type = 'button';
i.name='addLot';
i.value='Multiply 75';
i.classList.add("randomClassToHelpHide");
i.id='addLot';
function main() {
$('#main_navbar').append(i);
$(document).on('click',"#addLot", function() {
var allRows = $('#optionChainTable-indices > tbody > tr');
allRows.each(function(rowIndex) {
//2 , 3, 21, 22
var col = $(this).find("td:nth-child(2)");
var txt = parseInt($(col).text().split(",").join(""));
if (!isNaN(txt)) {
$(col).text(getNumber(txt));
}
col = $(this).find("td:nth-child(3)");
txt = parseInt($(col).text().split(",").join(""));
if (!isNaN(txt)) {
$(col).text(getNumber(txt));
}
col = $(this).find("td:nth-child(21)");
txt = parseInt($(col).text().split(",").join(""));
if (!isNaN(txt)) {
$(col).text(getNumber(txt));
}
col = $(this).find("td:nth-child(22)");
txt = parseInt($(col).text().split(",").join(""));
if (!isNaN(txt)) {
$(col).text(getNumber(txt));
}
});
changeButtonName();
});
$(document).on('change',"#expirySelect", function() {
isMultiply = false;
changeButtonName();
});
$(document).on('click',".fullViewBtn", function() {
$(".randomClassToHelpHide").remove();
$('#goBackSite').before(i);
});
$(document).on('click',"#goBackSite", function() {
$(".randomClassToHelpHide").remove();
$('#main_navbar').append(i);
});
}
main();