amazon command

Amazonの商品検索画面で、Amazon.jpから販売される商品のみが検索結果に表示されるようになるボタンを追加します。

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

Advertisement:

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

Advertisement:

// ==UserScript==
// @name         amazon command
// @namespace    amazon command
// @version      0.2
// @description  Amazonの商品検索画面で、Amazon.jpから販売される商品のみが検索結果に表示されるようになるボタンを追加します。
// @author       meguru
// @include      https://www.amazon.co.jp/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    const createButton = (label, cmd) => {
        const button = document.createElement('button');
        if (!button) { console.log('failed create ${label}') };
        button.innerHTML = label;
        button.onclick = () => {
            window.location.href += cmd;
        };
        return button;
    }

    const refArea = document.getElementById('s-refinements');
    if (!refArea) {
        console.log('not find refArea');
        return;
    };

    const fromAmazonJpButton = createButton('from amazon.jp', '&emi=AN1VRQENFRJN5');
    let res = refArea.parentNode.insertBefore(fromAmazonJpButton, refArea);
    if (!res) {
        console.log('failed add button');
        return;
    };

    const offButton = createButton('50% off', '&pct-off=50-');
    res = refArea.parentNode.insertBefore(offButton, refArea);
    if (!res) {
        console.log('failed add button');
        return;
    };

})();