|
6 | 6 | // @supportURL https://github.com/0xdevalias/userscripts/issues
|
7 | 7 | // @downloadURL https://github.com/0xdevalias/userscripts/raw/main/userscripts/amazon-prime-gaming-highlighter/amazon-prime-gaming-highlighter.user.js
|
8 | 8 | // @namespace https://www.devalias.net/
|
9 |
| -// @version 1.0.6 |
| 9 | +// @version 1.0.7 |
10 | 10 | // @match https://gaming.amazon.com/home
|
11 | 11 | // @grant GM_openInTab
|
12 | 12 | // ==/UserScript==
|
|
154 | 154 | return Array.from(document.querySelectorAll(sectionCardsSelector));
|
155 | 155 | }
|
156 | 156 |
|
| 157 | + function getBlocksInSection(section) { |
| 158 | + const sectionBlocksSelector = `div[data-a-target="${section}"] .offer-list__content__grid > .tw-block, div[data-a-target="${section}"] .grid-carousel__slide > .tw-block`; |
| 159 | + |
| 160 | + return Array.from(document.querySelectorAll(sectionBlocksSelector)); |
| 161 | + } |
| 162 | + |
157 | 163 | function getTitleForCard({ card, section }) {
|
158 | 164 | if (sectionsWithTitleInHeading.includes(section)) {
|
159 | 165 | return card.querySelector(
|
|
214 | 220 | }
|
215 | 221 |
|
216 | 222 | function collectClaimURLs() {
|
217 |
| - const claimButtons = new Set( |
218 |
| - Array.from(document.querySelectorAll('.item-card__claim-button a[href]')) |
219 |
| - .map((button) => button.href) |
220 |
| - .filter((url) => !url.includes('/web-games/')), |
221 |
| - ); |
| 223 | + const uniqueClaimURLs = new Set(); |
| 224 | + |
| 225 | + sectionsToMatch.forEach((section) => { |
| 226 | + if (sectionsToIgnore.includes(section)) { |
| 227 | + DEBUG && console.log(`[APGH] Skipping claim URL for ignored section=${section}`); |
| 228 | + return; |
| 229 | + } |
| 230 | + |
| 231 | + getBlocksInSection(section).forEach((sectionBlock) => { |
| 232 | + if (isItemCollected(sectionBlock)) { |
| 233 | + DEBUG && console.log(`[APGH] Skipping claim URL for collected item for section=${section}`); |
| 234 | + return; |
| 235 | + } |
| 236 | + |
| 237 | + Array.from( |
| 238 | + new Set( |
| 239 | + Array.from(sectionBlock.querySelectorAll('[data-a-target="learn-more-card"]')) |
| 240 | + .map(el => el.href) |
| 241 | + .filter((url) => !url.includes('/web-games/')) |
| 242 | + .map(href => href.replace('/details', '')) |
| 243 | + ) |
| 244 | + ).forEach(url => { |
| 245 | + DEBUG && console.log(`[APGH] Found claim URL: ${url}`); |
| 246 | + |
| 247 | + uniqueClaimURLs.add(url) |
| 248 | + }); |
| 249 | + }); |
| 250 | + }); |
222 | 251 |
|
223 |
| - return Array.from(claimButtons); |
| 252 | + return Array.from(uniqueClaimURLs); |
224 | 253 | }
|
225 | 254 |
|
226 | 255 | function copyURLsToClipboard(urls) {
|
|
0 commit comments