From e22d0b9287210585e0c6d34ca2e5851a71438749 Mon Sep 17 00:00:00 2001 From: Matthew Salcido Date: Wed, 20 Oct 2021 20:57:05 -0700 Subject: [PATCH 1/5] Update release-ratings to work with new release page --- html/learn.html | 2 ++ js/extension/features/release-ratings.js | 16 +++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/html/learn.html b/html/learn.html index 5cef14ec..f4a5642d 100644 --- a/html/learn.html +++ b/html/learn.html @@ -520,6 +520,8 @@

Marketplace Ratings

To see ratings, simply click the link that says "Show Ratings". It will be located above the "View Release Page" link on each release listing.

+

You can click the rating and it will open up the stats for that release in a new page where you can see the number of ratings, the haves, the wants, and the rating distribution.

+ diff --git a/js/extension/features/release-ratings.js b/js/extension/features/release-ratings.js index c6a45076..6095abe1 100644 --- a/js/extension/features/release-ratings.js +++ b/js/extension/features/release-ratings.js @@ -60,25 +60,31 @@ rl.ready(() => { * Gets the release rating and votes from a specified release * * @method getReleaseRating - * @param {String} id [the event's data-id attribute value] + * @param {String} url [the event's data-id attribute value] * @param {object} parent [the parent of the event.target element] * @return {object} */ - async function getReleaseRating(id, parent) { + async function getReleaseRating(url, parent) { try { - let response = await fetch(id), + let response = await fetch(url), data = await response.text(), div = document.createElement('div'), + id = parent.closest('tr').dataset.releaseId, + selector = '#release-stats div[class*="items_"] ul li:nth-child(4) a', + href = `/release/stats/${id}`, rating; div.innerHTML = data; - rating = div.querySelector('.statistics ul:first-of-type li:last-child').textContent; + rating = div.querySelector(selector).textContent; parent.querySelector('.preloader').remove(); - return parent.append(rating); + return parent.insertAdjacentHTML( + 'afterbegin', + `Ratings: ${rating}` + ); } catch (err) { From d247f0c6ea8dd9fa9c008c7e392e44c81f8075a0 Mon Sep 17 00:00:00 2001 From: Matthew Salcido Date: Wed, 20 Oct 2021 20:57:26 -0700 Subject: [PATCH 2/5] Fix quick-search; rename class --- js/extension/features/quick-search-react.js | 12 ++++++------ js/extension/features/quick-search.js | 8 ++++---- test/unauthenticated/quick-search.js | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/js/extension/features/quick-search-react.js b/js/extension/features/quick-search-react.js index 3e03dfb9..a52f8dbd 100644 --- a/js/extension/features/quick-search-react.js +++ b/js/extension/features/quick-search-react.js @@ -56,10 +56,10 @@ // CSS // ======================================================== let rules = ` - .de-one-click { + .de-quick-search { cursor: pointer; } - .de-one-click:hover { + .de-quick-search:hover { text-decoration: underline; } .de-external { @@ -69,7 +69,7 @@ opacity: 0; position: absolute; } - .de-one-click:hover + .de-external { + .de-quick-search:hover + .de-external { opacity: 1; text-decoration: none; } @@ -80,7 +80,7 @@ // ======================================================== let i = document.createElement('i'), query = document.title.replace(re, ''), - releaseTitle = document.querySelector('#release-header h1'); + releaseTitle = document.querySelector('h1[class*="title_"]'); // DOM manipulation i.classList = 'icon icon-external-link de-external'; @@ -88,13 +88,13 @@ let regex = /(\– .+)+$/g, titleText = releaseTitle.innerHTML.match(regex); - let newReleaseMarkup = releaseTitle.innerHTML.toString().replace(regex, `${titleText[0]}`); + let newReleaseMarkup = releaseTitle.innerHTML.toString().replace(regex, `${titleText[0]}`); releaseTitle.innerHTML = newReleaseMarkup; releaseTitle.insertAdjacentElement('beforeend', i); // Click handler - document.querySelector('.de-one-click').addEventListener('click', () => { + document.querySelector('.de-quick-search').addEventListener('click', () => { window.open('https://www.google.com/search?q=' + encodeURIComponent(query) + additionalText); }); diff --git a/js/extension/features/quick-search.js b/js/extension/features/quick-search.js index 41aa0f39..65f69fba 100644 --- a/js/extension/features/quick-search.js +++ b/js/extension/features/quick-search.js @@ -56,10 +56,10 @@ // CSS // ======================================================== let rules = ` - .de-one-click { + .de-quick-search { cursor: pointer; } - .de-one-click:hover { + .de-quick-search:hover { text-decoration: underline; } .de-external { @@ -69,7 +69,7 @@ opacity: 0; position: absolute; } - .de-one-click:hover + .de-external { + .de-quick-search:hover + .de-external { opacity: 1; text-decoration: none; } @@ -84,7 +84,7 @@ // DOM manipulation i.classList = 'icon icon-external-link de-external'; - releaseTitle.nextElementSibling.classList = 'de-one-click'; + releaseTitle.nextElementSibling.classList = 'de-quick-search'; releaseTitle.nextElementSibling.insertAdjacentElement('afterend', i); releaseTitle.nextElementSibling.textContent = releaseTitle.nextElementSibling.textContent.trim(); diff --git a/test/unauthenticated/quick-search.js b/test/unauthenticated/quick-search.js index e06b0f89..4b755320 100644 --- a/test/unauthenticated/quick-search.js +++ b/test/unauthenticated/quick-search.js @@ -5,9 +5,9 @@ let test = async function(page) { await toggleFeature('#toggleQuickSearch'); await Promise.all([ page.goto('https://www.discogs.com/Lou-Karsh-Phantom-Structures/release/13705345', { waitUntil: 'networkidle2' }), - page.waitFor('.de-one-click') + page.waitFor('.de-quick-search') ]); - let hasQuickSearch = await page.$eval('.de-one-click', elem => elem.classList.contains('de-one-click')); + let hasQuickSearch = await page.$eval('.de-quick-search', elem => elem.classList.contains('de-quick-search')); assert.equal(hasQuickSearch, true, 'Quick Search span was not rendered'); }; From 26df6c21d3d1e504e46a58f05024c793f910c3a1 Mon Sep 17 00:00:00 2001 From: Matthew Salcido Date: Wed, 20 Oct 2021 21:13:28 -0700 Subject: [PATCH 3/5] Inject scan button when no items are available for sale --- js/extension/features/release-scanner.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/extension/features/release-scanner.js b/js/extension/features/release-scanner.js index 9fee8929..a7da001f 100644 --- a/js/extension/features/release-scanner.js +++ b/js/extension/features/release-scanner.js @@ -262,7 +262,7 @@ rl.ready(() => { if ( rl.pageIs('artist', 'label') ) { - let selector = '.section_content.marketplace_box_buttons_count_1'; + let selector = 'div[class*="marketplace_box_buttons_count_"]'; if ( document.querySelector(selector) ) { From fb6814a19a61e72361e6a7de67b6e6ba8059e321 Mon Sep 17 00:00:00 2001 From: Matthew Salcido Date: Thu, 21 Oct 2021 19:59:06 -0700 Subject: [PATCH 4/5] Update change-log.js --- js/popup/change-log.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/js/popup/change-log.js b/js/popup/change-log.js index 26fd0ff7..08b1dbf0 100644 --- a/js/popup/change-log.js +++ b/js/popup/change-log.js @@ -1,7 +1,21 @@ module.exports = { current: [ { - version: '2.25.8', + version: '2.25.10', + features: [ + ], + updates: [ + { + name: 'Bugfix', + description: 'Updated the Marketplace Ratings feature to work with the new Release Page. Fixed Quick Search. And the Release Scanner will now add the scan button even when there are no items for sale.' + }, + ], + thanks: [] + }, + ], + previous: [ + { + version: '2.25.9', features: [ ], updates: [ @@ -16,8 +30,6 @@ module.exports = { ], thanks: ['A big thank you to Tobias B. for his kind donation! And shout out to Sonny C. for the bug report!'] }, - ], - previous: [ { version: '2.25.7', features: [ From 20be6f8b4ee994577427655e289416131aaecbb4 Mon Sep 17 00:00:00 2001 From: Matthew Salcido Date: Thu, 21 Oct 2021 19:59:22 -0700 Subject: [PATCH 5/5] Version bump to 2.25.10 --- manifest.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/manifest.json b/manifest.json index 40db91ce..78c571bd 100644 --- a/manifest.json +++ b/manifest.json @@ -3,7 +3,7 @@ "name": "Discogs Enhancer", "short_name": "Discogs Enhancer", "description": "Adds a dark theme, block sellers, price comparisons, currency converter, configurable quick search, & more to Discogs!", - "version": "2.25.9", + "version": "2.25.10", "author": "Matthew Salcido", "homepage_url": "https://www.discogs-enhancer.com", "browser_action": { diff --git a/package.json b/package.json index bb0e5500..d41a2fe0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "discogs-enhancer", - "version": "2.25.9", + "version": "2.25.10", "description": "A Chrome extension that adds useful functionality to Discogs.com! https://www.discogs-enhancer.com", "main": "index.js", "scripts": {