-
Notifications
You must be signed in to change notification settings - Fork 61
/
Copy pathbetterTradingeconomics.user.js
103 lines (85 loc) · 3.83 KB
/
betterTradingeconomics.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
101
102
103
// ==UserScript==
// @name betterTradingeconomics
// @namespace https://github.com/amit0rana/betterTradingeconomics
// @version 0.04
// @description Introduces small features on top of betterTradingeconomics site
// @author Amit
// @match https://tradingeconomics.com/*
// @match https://in.investing.com/*
// @grant GM_addStyle
// @require https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js
// @require https://raw.githubusercontent.com/amit0rana/MonkeyConfig/master/monkeyconfig.js
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js
// @require https://raw.githubusercontent.com/amit0rana/betterOptionsTrading/master/betterCommon.js
// @downloadURL https://github.com/amit0rana/betterOptionsTrading/raw/master/betterTradingeconomics.user.js
// @updateURL https://github.com/amit0rana/betterOptionsTrading/raw/master/betterTradingeconomics.meta.js
// ==/UserScript==
const D_LEVEL = D_LEVEL_NONE;
var currentUrl = window.location.pathname;
console.log(currentUrl);
//tradingeconomics.com
function stockFilter() {
if (currentUrl.includes('stocks')) {
const domForAdPanel = '[data-ad=ad-below-menu]';
//$('div#ctl00_ctl07_AdPanel').hide();
$(domForAdPanel).hide();
//jQ(allDOMPaths.PathForPositions).filter(':has(:checkbox:checked)');
var statuses = [];
var selectBox = document.createElement("SELECT");
selectBox.id = "toggleSelectboxID";
selectBox.classList.add("randomClassToHelpHide");
//selectBox.style="margin: 15px 0;margin-top: 15px;margin-right: 0px;margin-bottom: 15px;margin-left: 0px;background-color: var(--color-bg-default)"
var option = document.createElement("option");
option.text = "Show All";
option.value= "All";
selectBox.add(option);
var statusesRows = $('td#session > span');
console.log(statusesRows.length);
statusesRows.each(function(rowIndex) {
var title = $(this).attr('title');
if (!statuses.includes(title)) {
statuses.push(title);
var option = document.createElement("option");
option.text = title;
option.value = title;
selectBox.add(option);
}
});
console.log(statuses);
selectBox.addEventListener("change", function() {
var selectedItem = this.value;
var allRows = $('tr');
allRows.each(function(rowIndex) {
if ($(this).find('th').length > 0) {
return;
}
var session = $(this).find(`[title='${selectedItem}']`);
if (selectedItem === 'All' ) {
$(this).show();
} else if (session.length > 0) {
$(this).show();
} else {
$(this).hide();
}
});
});
$('#toggleSelectboxID').remove();
//$(domForAdPanel).after(selectBox);
$(".col-lg-10 > div:nth-child(5)").before(selectBox);
var refreshBtn = document.createElement("button");
refreshBtn.id = "refreshID";
refreshBtn.type = "button";
refreshBtn.innerHTML = "Refresh";
refreshBtn.addEventListener("click", function() {
stockFilter();
});
$('#refreshID').remove();
$(domForAdPanel).after(refreshBtn);
}
}
stockFilter();
//investing.in
function hideAds() {
$('div.ads').hide();
}
hideAds();