-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFutbin-Plus.user.js
More file actions
102 lines (89 loc) · 3.39 KB
/
Futbin-Plus.user.js
File metadata and controls
102 lines (89 loc) · 3.39 KB
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
// ==UserScript==
// @name Futbin Plus
// @name:en Futbin Plus
// @namespace iN4sser
// @match *://*.futbin.com/*/squad/*
// @match *://*.futbin.com/*/player/*
// @run-at document-end
// @grant none
// @version 1.2.4
// @author Nasser Alrayes
// @downloadURL https://github.com/iN4sser/Userscript/raw/main/Futbin-Plus.user.js
// @updateURL https://github.com/iN4sser/Userscript/raw/main/Futbin-Plus.user.js
// @description Adding some features to Futbin
// @description:en Adding some features to Futbin
// @license MIT
// ==/UserScript==
// Squad rating statistics
if (window.location.href.includes('futbin.com') && window.location.href.includes('/squad/')) {
function displayTotalPlayerRating() {
'use strict';
const elementList = Array.from(document.querySelectorAll('#area .pcdisplay-rat'));
const numbers = elementList.reduce((obj, element) => {
const elementText = element.textContent;
const elementNumbers = elementText.match(/\d+/g);
if (elementNumbers) {
elementNumbers.forEach(number => {
obj[number] = (obj[number] || 0) + 1;
});
}
return obj;
}, {});
const resultDiv = document.createElement('div');
resultDiv.className = 'TotalRating';
const resultHtml = Object.entries(numbers).map(([number, count]) => `
<span class="Number">${number}</span>
<span class="Count">${count}</span>
<br>
`).join('');
resultDiv.innerHTML = resultHtml;
document.querySelector('#area').appendChild(resultDiv);
}
// CSS
const style = document.createElement('style');
style.innerHTML = `
.TotalRating {
margin-top: 10px;
}
.Number, .Count {
display: inline-block;
width: 30px;
height: 20px;
margin: 1px;
font-size: 14px;
line-height: 1;
text-align: center;
padding: 5px;
text-transform: uppercase;
cursor: pointer;
transition: .35s;
border-radius: 3px;
box-shadow: 0 2px 5px 0 rgba(0,0,0,.16), 0 2px 10px 0 rgba(0,0,0,.12);
}
.Number {
background: #00ffae;
color: #212121;
}
.Count {
background: #292929;
color: #fff;
}
`;
document.head.appendChild(style);
displayTotalPlayerRating();
}
// YouTube Player Review
if (window.location.href.match(/.*:\/\/.*\.futbin\.com\/.*\/player\/.*/)) {
function addYouTubeButton() {
'use strict';
const playerPage = document.querySelector("#Player-card > div.pcdisplay-rat");
const playerNameElement = document.querySelector("#Player-card > div.pcdisplay-name");
const playerName = playerNameElement ? playerNameElement.textContent.trim() : "";
const searchUrl = `https://www.youtube.com/results?search_query=${playerPage.textContent.trim()} ${playerName} Review`;
const iconUrl = 'https://www.youtube.com/s/desktop/0953dc72/img/favicon_48x48.png';
const iconHtml = `<a href="${searchUrl}" target="_blank"><img src="${iconUrl}" class="YouTubePlayerReview" style="display: unset; line-height: 2.7;"></a>`;
const shareTooltip = document.querySelector('.link-holder.inline-block.pt-2');
shareTooltip.insertAdjacentHTML('afterend', iconHtml);
}
window.addEventListener('load', addYouTubeButton);
}