-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathHBCCS.user.js
50 lines (43 loc) · 1.87 KB
/
HBCCS.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
// ==UserScript==
// @name Humble Bundle Current Country Spy
// @description Show current Humble Bundle country in navbar.
// @author Cloud
// @namespace https://github.com/xPixv/Humble-Bundle-Current-Country-Spy
// @supportURL https://github.com/xPixv/Humble-Bundle-Current-Country-Spy/issues
// @version 1.1.7
// @downloadURL https://github.com/xPixv/Humble-Bundle-Current-Country-Spy/raw/master/HBCCS.user.js
// @icon https://humblebundle-a.akamaihd.net/static/hashed/46cf2ed85a0641bfdc052121786440c70da77d75.png
// @include https://www.humblebundle.com/*
// @grant unsafeWindow
// @run-at document-end
// ==/UserScript==
(function () {
'use strict';
const showCountry = () => {
try {
const country = unsafeWindow.models.request.country_code;
let node = document.getElementsByClassName('tabs tabs-navbar-item');
if (node.item(0)) {
let elem = document.createElement('a');
elem.setAttribute('class', 'navbar-item not-dropdown button-title');
elem.href = "#";
elem.innerHTML = '<span class="navbar-icon-text-wrapper"><i class="navbar-item-icon hb hb-star-o mobile"></i><span class="navbar-item-text">'+country+'</span></span>';
node.item(0).append(elem);
}
node = document.getElementsByClassName('mm-listview');
if (node.item(0)) {
let elem = document.createElement('li');
elem.setAttribute('class', 'mm-listitem');
elem.innerHTML = '<a href="#" class="mm-listitem__text">'+country+'</a>';
node.item(0).append(elem);
}
} catch (e) {
setTimeout(() => {
showCountry();
}, 500);
}
};
setTimeout(() => {
showCountry();
}, 100);
})();