├── .gitignore ├── icons ├── off2.png └── on2.png ├── manifest.json ├── README.md ├── background.js └── main.js /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | -------------------------------------------------------------------------------- /icons/off2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quikky/chrome-extension-amazon_seller-filter/HEAD/icons/off2.png -------------------------------------------------------------------------------- /icons/on2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quikky/chrome-extension-amazon_seller-filter/HEAD/icons/on2.png -------------------------------------------------------------------------------- /manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "manifest_version": 3, 3 | "name": "AmazonSeller Filter", 4 | "version": "0.1.0", 5 | "description": "amazon seller filter of amazon.co.jp", 6 | "icons": { 7 | "128": "icons/on2.png" 8 | }, 9 | "background": { 10 | "service_worker": "background.js" 11 | }, 12 | "action": {}, 13 | "permissions": [ 14 | "scripting", 15 | "activeTab", 16 | "webRequest" 17 | ], 18 | "host_permissions": [ 19 | "https://www.amazon.co.jp/" 20 | ] 21 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # chrome-extension-amazon_seller-filter 2 | Javascript + Chrome APIs => Chrome Extension 3 | 4 | ## About 5 | seller filter (by amazon.co.jp) for Amazon.co.jp 6 | 7 | ## How to Use 8 | 1. add Extension [AmazonSeller Filter](https://chrome.google.com/webstore/detail/amazonseller-filter/apmbaomfhdbgpadahpbafpjgbhhcdege?hl=ja) 9 | 2. Check Status Enabled (enabled:orange, disabled:gray) Browser Action. 10 | 3. keyward search for Amazon.co.jp 11 | 4. SearchResult Amazon.co.jp Seller only. 12 | 13 | * bug pull request plz :) -------------------------------------------------------------------------------- /background.js: -------------------------------------------------------------------------------- 1 | var toggle = true; 2 | 3 | chrome.action.onClicked.addListener(() => { 4 | toggle = !toggle; 5 | if (toggle) { 6 | chrome.action.setIcon({ 7 | path: "icons/on2.png" 8 | }); 9 | } else { 10 | chrome.action.setIcon({ 11 | path: "icons/off2.png" 12 | }); 13 | } 14 | }); 15 | 16 | chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => { 17 | if (!toggle) { 18 | return 19 | } 20 | if (tab.url.match('https://www.amazon.co.jp/')) { 21 | chrome.scripting.executeScript({ 22 | target: { tabId: tab.id }, 23 | files: ['main.js'], 24 | }); 25 | } 26 | }); -------------------------------------------------------------------------------- /main.js: -------------------------------------------------------------------------------- 1 | var sellerFilter = "&rh=p_6%3AAN1VRQENFRJN5"; 2 | var whitelist = [ 3 | "aps", 4 | "stripbooks", 5 | "english-books", 6 | "popular", 7 | "classical", 8 | "dvd", 9 | "videogames", 10 | "software", 11 | "computers", 12 | "electronics", 13 | "office-products", 14 | "kitchen", 15 | "pets", 16 | "hpc", 17 | "beauty", 18 | "luxury-beauty", 19 | "food-beverage", 20 | "baby", 21 | "fashion", 22 | "fashion-womens", 23 | "fashion-mens", 24 | "fashion-baby-kids", 25 | "apparel", 26 | "shoes", 27 | "watch", 28 | "jewelry", 29 | "toys", 30 | "hobby", 31 | "mi", 32 | "sporting", 33 | "automotive", 34 | "diy", 35 | "appliances", 36 | "gift-cards", 37 | "industrial" 38 | ]; 39 | 40 | var targets = function (list) { 41 | let targetsString = ""; 42 | for (let value of list) { 43 | targetsString += `&i=${value}|search-alias%3D${value}|` 44 | } 45 | return targetsString.slice(0, -1); 46 | } 47 | 48 | var aps = function () { 49 | if(location.search.match("&sprefix=")) { 50 | return !!location.search.split('&').find((param) => { 51 | if (param.match("sprefix=") && param.match("%2Caps%2C")) { 52 | return true; 53 | } 54 | }) 55 | } else { 56 | return !location.search.match("&i="); 57 | } 58 | } 59 | (function () { 60 | targetURL = location.href; 61 | if (targetURL.match(sellerFilter)) return 62 | if ( 63 | targetURL.match("amazon.co.jp/s\\?k=") && 64 | (targetURL.match(targets(whitelist)) || aps) && 65 | !targetURL.match("&k=&|.*&field-keywords=$") 66 | ) { 67 | location.href = targetURL + sellerFilter 68 | } 69 | }()); --------------------------------------------------------------------------------