-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnintendo.user.js
More file actions
196 lines (172 loc) · 7.02 KB
/
nintendo.user.js
File metadata and controls
196 lines (172 loc) · 7.02 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
// ==UserScript==
// @name GazelleGames Nintendo Uploady
// @namespace https://gazellegames.net/
// @version 1.1.4
// @description Uploady for Nintendo sites
// @author FinalDoom
// @match https://gazellegames.net/upload.php*
// @match https://gazellegames.net/torrents.php?action=editgroup&*
// @match https://gazellegames.net/torrents.php?id=*
// @match https://gazellegames.net/upload.php?groupid=*
// @match https://gazellegames.net/torrents.php?action=edit&*
// @match https://www.nintendo.com/store/products/*/*
// @match https://www.nintendo.co.uk/Games/*
// @match https://store-jp.nintendo.com/list/software/*
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_deleteValue
// @require https://code.jquery.com/jquery-3.6.0.min.js
// @require https://raw.githubusercontent.com/tengattack/html2bbcode.js/master/lib/html2bbcode.js
// @require https://raw.githubusercontent.com/FinalDoom/gazelle-uploady/master/common.js
// ==/UserScript==
'use strict';
const JP_YOUTUBE_THUMB_RE = /img.youtube.com\/vi\/([^\/]+)\//;
function getGameInfoJP() {
const nintendo = new GameInfo();
nintendo.platform = $('th:contains("対応ハード")').next().text().trim();
nintendo.title = $('.productDetail--headline__title').text().trim();
const publisher = $('th:contains("メーカー")').next().text().trim();
nintendo.addLanguage(...$('th:contains("対応言語")').next().text().trim().split(', '));
const descriptionHtml = $('<div>')
.append($('.productDetail--catchphrase__title, .productDetail--catchphrase__longDescription').clone())
.html();
nintendo.description = `${descriptionHtml}
[spoiler=Original Japanese description]
${descriptionHtml}
[/spoiler]`;
nintendo.addTag(
...$('.productDetail--tag__label')
.map((_, elem) => $(elem).text().trim())
.toArray(),
);
nintendo.year = $('th:contains("配信日")').next().text();
nintendo.rating = $('.productDetail--CERO__rating img, .productDetail--IARC__rating img').first().attr('alt');
nintendo.cover = $('ul.slick-dots li:first-of-type() img').attr('src').split('?')[0];
$('.slick-track li.slick-slide:not(.slick-cloned) img')
.map((_, elem) => $(elem).attr('src').split('?')[0])
.toArray()
.forEach((url) => {
if (JP_YOUTUBE_THUMB_RE.test(url)) {
// This actually references a youtube video. Use it as the trailer
const trailer = 'https://youtu.be/' + url.match(JP_YOUTUBE_THUMB_RE)[1];
if (nintendo.trailer) {
// Put it in extraInfo instead (sometimes there are multiple videos)
if ('videos' in nintendo.extraInfo) {
nintendo.extraInfo = {videos: nintendo.extraInfo + ', ' + trailer};
} else {
nintendo.extraInfo = {videos: trailer};
}
} else {
nintendo.trailer = trailer;
}
} else if (url !== nintendo.cover) {
nintendo.addScreenshot(url);
}
});
nintendo.extraInfo = {
publisher: publisher,
storeLink: window.location.toLocaleString(),
};
return nintendo;
}
function getGameInfoUS() {
const nintendo = new GameInfo();
nintendo.platform = $('[class^="Herostyles__HeroSection"] [class^="Herostyles__PlatformContainer"] span')
.text()
.trim();
nintendo.title = $('[class^="Breadcrumbsstyles__StyledNav"] li:last-of-type').text().trim();
const publisher = $(
'[class^="ProductInfostyles__InfoRow"]:contains("Publisher") [class^="ProductInfostyles__InfoDescr"]',
)
.text()
.trim();
nintendo.addLanguage(
...$(
'[class^="ProductInfostyles__InfoRow"]:contains("Supported languages") [class^="ProductInfostyles__InfoDescr"] div',
)
.map(function () {
return $(this).text().trim();
})
.toArray(),
);
nintendo.description = $('[class^="ReadMorestyles__ReadMore"] [class^="RichTextstyles__Html"]').html();
nintendo.addTag(
...$('[class^="ProductInfostyles__InfoRow"]:contains("Genre") [class^="ProductInfostyles__InfoDescr"] div')
.map(function () {
return $(this).text();
})
.toArray()
.filter((lang) => lang !== 'Other'),
);
nintendo.year = $(
'[class^="ProductInfostyles__InfoRow"]:contains("Release date") [class^="ProductInfostyles__InfoDescr"]',
).text();
nintendo.rating = $(
'[class^="ProductInfostyles__InfoRow"]:contains("ESRB rating") [class^="ProductInfostyles__InfoDescr"]',
).text();
const imageBiggerer = /(c_scale)[^\/]+/;
const images = $('[class*="MediaGallerystyles__ModalCarousel"] .slider-slide img');
nintendo.cover = images.first().attr('src').replace(imageBiggerer, '$1') + '.jpg';
nintendo.addScreenshot(
...images
.slice(1)
.map(function () {
return $(this).attr('src').replace(imageBiggerer, '$1') + '.jpg'; // JPG for ptpimg
})
.toArray(),
);
nintendo.extraInfo = {
publisher: publisher,
storeLink: window.location.toLocaleString().replace(/store\/products/, 'games/detail'),
};
return nintendo;
}
function getGameInfoUK() {
const nintendo = new GameInfo();
// #region Fetch wiki info UK, test NA
nintendo.platform = $('.listwheader-container .info_system .game_info_title:contains("System")').next().text();
nintendo.title = $('.gamepage-header-info h1').text().trim();
const publisher = $('#gameDetails .game_info_title:contains("Publisher")').next().text().trim();
nintendo.addLanguage(
...$('.listwheader-container .info_system .game_info_title:contains("Languages")').next().text().split(', '),
);
nintendo.description = $('.content').html(); // Oddly simple
nintendo.addTag(...$('#gameDetails .game_info_title:contains("Categories")').next().text().trim().split(', '));
nintendo.year = $('.game_info_title:contains("Release date")').next().text();
nintendo.rating = $('#gameDetails .game_info_title:contains("Age rating")').next().find('.age-rating__icon').text();
nintendo.cover = $('.packshot-hires img').attr('src').split('?')[0];
if (unsafeWindow._gItems) {
const images = unsafeWindow._gItems;
const videoInfo = images.filter((o) => o.isVideo);
if (videoInfo && videoInfo[videoInfo.length - 1]) {
nintendo.trailer = videoInfo[videoInfo.length - 1].video_content_url;
}
nintendo.addScreenshot(...images.filter((o) => !o.isVideo).map((i) => i.image_url.split('?')[0]));
} else {
nintendo.screenshots = [];
}
nintendo.extraInfo = {
publisher: publisher,
storeLink: window.location.toLocaleString(),
};
return nintendo;
}
(function () {
('use strict');
const factory = new UploadyFactory();
factory.build(
'Search Nintendo (UK)',
(title) => `https://www.nintendo.co.uk/Search/Search-299117.html?q=${title}`,
(resolve) => resolve(getGameInfoUK()),
);
factory.build(
'(JP)',
(title) => `https://store-jp.nintendo.com/search/?q=${title}`,
(resolve) => resolve(getGameInfoJP()),
);
factory.build(
'(US)',
(title) => `https://www.nintendo.com/search/?q=${title}&p=1&cat=gme&sort=df`,
(resolve) => resolve(getGameInfoUS()),
);
})();