Skip to content

Commit

Permalink
add link to options in amazon footer
Browse files Browse the repository at this point in the history
  • Loading branch information
tadwohlrapp committed Jun 16, 2022
1 parent 2066fb6 commit 12d8157
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 26 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

<img width="752" alt="image" src="https://user-images.githubusercontent.com/2788192/174012811-0c90facd-74d2-4e48-a2e7-22d89e832a0e.png">

## 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)
Expand Down
10 changes: 8 additions & 2 deletions userscript/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

<img width="752" alt="image" src="https://user-images.githubusercontent.com/2788192/174012811-0c90facd-74d2-4e48-a2e7-22d89e832a0e.png">

## 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)
Expand Down
47 changes: 25 additions & 22 deletions userscript/soldby.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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==
Expand Down Expand Up @@ -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();
Expand All @@ -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')
};

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 12d8157

Please sign in to comment.