From 12d815746b14e281ff209e1ac6a63bc1262c64eb Mon Sep 17 00:00:00 2001 From: Tad Wohlrapp Date: Thu, 16 Jun 2022 09:14:46 +0200 Subject: [PATCH] add link to options in amazon footer --- README.md | 10 +++++++-- userscript/README.md | 10 +++++++-- userscript/soldby.user.js | 47 +++++++++++++++++++++------------------ 3 files changed, 41 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 53af41a..99ab2be 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,17 @@ [![Install](https://img.shields.io/badge/-Install-%23607f01?style=flat-square&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAYAAADhAJiYAAAAb0lEQVR4Ae3UgQUAMRBE0SvnykhnW0JKSmn/AANikbiB+SxgeWCelBwBA6jmxp+goq8CCiiggE4D3s3oLfrW5vc9RU3uNR9lRwnjRwljQDUYM0oYP0oYA6rBmFHC+FHC2FHCqJSA4n4VUAsyllL6AHMEW1GSXWKaAAAAAElFTkSuQmCC)](https://greasyfork.org/scripts/402064/code/script.user.js 'Click to install from greasyfork.org') [![Report Issue](https://img.shields.io/badge/-Report%20issue-%23c3513b?style=flat-square&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAYAAADhAJiYAAAAsklEQVR4Ae3UEQzEQBCF4YVzd66nrvWs0+JBPeNUdzzPYT11Onen/3TwLbyl+ZPBSb5sstOq1VXAAEKc7sZczPf2Y3woPyajfBg/yo/JKDfmTr/qVlHOl4m0F+hpKGAAGEG5roBiISgKVKACGQ6jFyRUoAc4gA78HKCTufa025lrKKAX8EFvS7sHeleTmkd9gQ3YgWcWY0ClDBgvKmEMKCNGR/kxflTCuFAnEOKMVlWL+wNsSof8wQFurAAAAABJRU5ErkJggg==)](https://github.com/tadwohlrapp/soldby/issues 'Click to report issue') -This userscript displays third party seller's name, country of origin and ratings on Amazon's search results and bestsellers pages. It also highlights sellers from specific countries (Default is China and Hong Kong, but can be set for anything). +This userscript displays third party seller's name, country of origin and ratings on Amazon. + +It also highlights sellers from China and Hong Kong. + +To set different countries in the script's options scroll to the very bottom of the amazon page and click this little button: + +image ## Compatibility -This script works on all Amazon marketplaces which publish third party seller's addresses on their Seller Information Page. At this point those are (in alphabetical order): +This script works on all Amazon marketplaces which publish third party seller's addresses on their seller profile page. At this point those are (in alphabetical order): - 🇯🇵 amazon.co.jp - 🇬🇧 amazon.co.uk (+ smile) diff --git a/userscript/README.md b/userscript/README.md index bc19411..e6382d3 100644 --- a/userscript/README.md +++ b/userscript/README.md @@ -2,11 +2,17 @@ [![Report Issue](https://img.shields.io/badge/-Report%20issue-%23c3513b?style=flat-square&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAYAAADhAJiYAAAAsklEQVR4Ae3UEQzEQBCF4YVzd66nrvWs0+JBPeNUdzzPYT11Onen/3TwLbyl+ZPBSb5sstOq1VXAAEKc7sZczPf2Y3woPyajfBg/yo/JKDfmTr/qVlHOl4m0F+hpKGAAGEG5roBiISgKVKACGQ6jFyRUoAc4gA78HKCTufa025lrKKAX8EFvS7sHeleTmkd9gQ3YgWcWY0ClDBgvKmEMKCNGR/kxflTCuFAnEOKMVlWL+wNsSof8wQFurAAAAABJRU5ErkJggg==)](https://github.com/tadwohlrapp/soldby/issues 'Click to report issue') -This userscript displays third party seller's name, country of origin and ratings on Amazon's search results and bestsellers pages. It also highlights sellers from specific countries (Default is China and Hong Kong, but can be set for anything). +This userscript displays third party seller's name, country of origin and ratings on Amazon. + +It also highlights sellers from China and Hong Kong. + +To set different countries in the script's options scroll to the very bottom of the amazon page and click this little button: + +image ## Compatibility -This script works on all Amazon marketplaces which publish third party seller's addresses on their Seller Information Page. At this point those are (in alphabetical order): +This script works on all Amazon marketplaces which publish third party seller's addresses on their seller profile page. At this point those are (in alphabetical order): - 🇯🇵 amazon.co.jp - 🇬🇧 amazon.co.uk (+ smile) diff --git a/userscript/soldby.user.js b/userscript/soldby.user.js index 1f3b9ba..84262a0 100644 --- a/userscript/soldby.user.js +++ b/userscript/soldby.user.js @@ -11,7 +11,7 @@ // @description:it Mostra il nome, il paese di origine e le valutazioni per i venditori di terze parti su Amazon (e mette in evidenza i venditori cinesi) // @namespace https://github.com/tadwohlrapp // @author Tad Wohlrapp -// @version 1.4.1 +// @version 1.5.0 // @license MIT // @homepageURL https://github.com/tadwohlrapp/soldby // @supportURL https://github.com/tadwohlrapp/soldby/issues @@ -35,7 +35,6 @@ // @require https://openuserjs.org/src/libs/sizzle/GM_config.min.js // @grant GM_getValue // @grant GM_setValue -// @grant GM_registerMenuCommand // @compatible firefox Tested on Firefox v101 with Violentmonkey v2.13.0, Tampermonkey v4.17.6161 and Greasemonkey v4.11 // @compatible chrome Tested on Chrome v102 with Violentmonkey v2.13.0 and Tampermonkey v4.16.1 // ==/UserScript== @@ -87,18 +86,8 @@ backdrop.style.display = 'block'; const buttons = frame.querySelectorAll('button'); - - function wrap(el, p) { - const wrapper = document.createElement('span'); - el.classList.add('a-button-inner', 'a-button-text'); - wrapper.classList.add('a-button', 'a-spacing-top-mini'); - if (p) wrapper.classList.add('a-button-primary'); - el.parentNode.insertBefore(wrapper, el); - wrapper.appendChild(el); - } - - wrap(buttons[0], true); - wrap(buttons[1], false); + wrapBtn(buttons[0], true); + wrapBtn(buttons[1]); backdrop.addEventListener('click', () => { GM_config.close(); @@ -120,20 +109,23 @@ 'frame': frame }); - GM_registerMenuCommand('Open "SoldBy" Settings', () => { - GM_config.open() - }) + // Link to Settings in Footer: + try { + const settingsLink = document.createElement('button'); + const navFooterCopyright = document.querySelector('.navFooterCopyright'); + navFooterCopyright.appendChild(settingsLink); + settingsLink.addEventListener('click', () => { GM_config.open(); }); + settingsLink.textContent = '⚙️ SoldBy'; + wrapBtn(settingsLink, false, true); + } catch { + console.error('Could not add settings link'); + } const countriesArr = GM_config.get('countries').split(/(?:,| )+/); if (GM_config.get('unknown')) countriesArr.push('?'); const options = { highlightedCountries: countriesArr, - // Country codes as per ISO 3166-1 alpha-2 - // Set this to [] to highlight no sellers at all - // Set it to ['FR'] to highlight sellers from France - // '?' means country is unknown due to seller having incomplete/invalid profile - // Default: ['?', 'CN', 'HK'] hideHighlightedProducts: GM_config.get('hide') }; @@ -646,6 +638,17 @@ return String.fromCodePoint(...codePoints); } + // wrap function to create buttons with amazon's ui + function wrapBtn(el, primary = false, small = false) { + const wrapper = document.createElement('span'); + el.classList.add('a-button-inner', 'a-button-text'); + wrapper.classList.add('a-button'); + if (primary) wrapper.classList.add('a-button-primary'); + if (small) wrapper.classList.add('a-button-small'); + el.parentNode.insertBefore(wrapper, el); + wrapper.appendChild(el); + } + function addGlobalStyle(css) { const head = document.getElementsByTagName('head')[0]; if (!head) return;