Amazon.com Item Not FBA

Know when viewing non-FBA item pages

Устаревшая версия за 05.01.2021. Перейдите к последней версии.

Чтобы установить этот скрипт, вы сначала должны установить расширение браузера, например Tampermonkey, Greasemonkey или Violentmonkey.

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

Чтобы установить этот скрипт, вы сначала должны установить расширение браузера, например Tampermonkey или Violentmonkey.

Чтобы установить этот скрипт, вы сначала должны установить расширение браузера, например Tampermonkey или Userscripts.

Чтобы установить этот скрипт, сначала вы должны установить расширение браузера, например Tampermonkey.

Чтобы установить этот скрипт, вы должны установить расширение — менеджер скриптов.

(у меня уже есть менеджер скриптов, дайте мне установить скрипт!)

Чтобы установить этот стиль, сначала вы должны установить расширение браузера, например Stylus.

Чтобы установить этот стиль, сначала вы должны установить расширение браузера, например Stylus.

Чтобы установить этот стиль, сначала вы должны установить расширение браузера, например Stylus.

Чтобы установить этот стиль, сначала вы должны установить расширение — менеджер стилей.

Чтобы установить этот стиль, сначала вы должны установить расширение — менеджер стилей.

Чтобы установить этот стиль, сначала вы должны установить расширение — менеджер стилей.

(у меня уже есть менеджер стилей, дайте мне установить скрипт!)

// ==UserScript==
// @name        Amazon.com Item Not FBA
// @description Know when viewing non-FBA item pages
// @author      dehotjava
// @namespace   https://greasyfork.org/en/scripts/407562-amazon-item-not-fba
// @match       https://*.amazon.com/dp/*
// @match       https://*.amazon.com/*/dp/*
// @match       https://*.amazon.com/gp/product/*
// @match       https://*.amazon.com/*/ASIN/*
// @match       https://*.amazon.ca/dp/*
// @match       https://*.amazon.ca/*/dp/*
// @match       https://*.amazon.ca/gp/product/*
// @match       https://*.amazon.ca/*/ASIN/*
// @run-at      document-idle
// @version     17
// @grant       none
// @icon        https://www.amazon.com/favicon.ico
// ==/UserScript==

var txt_caution = null
var txt_caution_cart = null

var selected_section = null

var cart_fly = document.getElementById('nav-flyout-ewc')
var cart_add = document.getElementById('submit.add-to-cart') || document.getElementById('submit.add-to-cart-ubb')
var cart_section = document.getElementById('submit.add-to-cart').closest('.a-box-inner').children

var info_merchant = document.getElementById('submit.add-to-cart').closest('.a-box-inner').children[0]
var info_oos = document.getElementById('outOfStock') || document.getElementById('backInStock')
var info_unqual = document.getElementById('unqualifiedBuyBox')

// normal section and another section (i.e. subscribe and save, used, etc.)
if (document.querySelectorAll('div[role="radio"][aria-checked="true"]').length > 0) {
    update_selected_section()

    // check fba again when other section selected
    for (const li of document.querySelectorAll('div[role="radio"]')) {
        li.addEventListener('click', function() {
            setTimeout(function() {
                update_selected_section()
                delay_check_fba()
            }, 1500)
        })
    }
}

// selected new product variant by drop down menu and etc.
var observer = new MutationObserver(function (event) {
    delay_check_fba()
})

observer.observe(document.getElementById('unifiedPrice_feature_div'), {
    attributes: true,
    attributeFilter: ['class'],
    childList: false,
    characterData: false
})

// selected new product variant by side-by-side buttons
if (document.getElementById('twister') != null) {
    for (const li of document.querySelectorAll('#twister>div>ul>li')) {
        li.addEventListener('click', function() {
            location.href = li.getAttribute('data-dp-url')
        })
    }
}

// check fba after document loaded
check_fba()

function delay_check_fba() {
    setTimeout(function(){
        check_fba()
    }, 1000)
}

function update_selected_section() {
    info_merchant = selected_section = document.querySelectorAll('div[role="radio"][aria-checked="true"]')[0].parentElement
}

function check_fba() {
    if (
        (info_merchant != null &&
         info_merchant.innerText.search('Fulfilled by Amazon') == -1 &&
         info_merchant.innerText.search('Ships from and sold by Amazon.') == -1 &&
         info_merchant.innerText.search('Ships from\nAmazon') == -1 &&
         info_merchant.innerText.search('To buy, select') == -1 &&
         info_merchant.innerText.search('Early Access') == -1 &&
         info_merchant.innerText.search('Kindle Price') == -1 &&
         info_merchant.innerText.search('audiobook') == -1
        ) &&
        !(info_oos != null) &&
        !(info_unqual != null)
    ) {

        console.log(info_merchant)
        console.log(info_merchant.innerText)

        if (cart_fly != null && document.getElementById('nav-flyout-ewc').style.cssText.search('right') != -1) {
            cart_fly.style.marginRight = '8px'
            cart_fly.style.marginTop = '7px'
            cart_fly.style.clipPath = "inset(0px 0px 14px 0px)"
        }

        if (document.getElementById('skiplink') != null) {
            document.getElementById('skiplink').remove()
        }

        document.body.style.border = 'red'
        document.body.style.borderStyle = 'inset'
        document.body.style.borderWidth = '0.5em'

        if (txt_caution != null) {
            txt_caution.remove()
        }

        if (txt_caution_cart != null) {
            txt_caution_cart.remove()
        }

        txt_caution = document.createElement("p")
        txt_caution.id = 'notfba'
        txt_caution.innerHTML = '* THIS ITEM IS NOT FULFILLED BY AMAZON *'
        txt_caution.style.background = 'black'
        txt_caution.style.color = 'red'
        txt_caution.style.fontSize = 'xx-large'
        txt_caution.style.margin = 'inherit'
        txt_caution.style.textAlign = 'center'
        txt_caution.style.textTransform = 'uppercase'
        document.documentElement.insertAdjacentElement('afterbegin', txt_caution)

        txt_caution_cart = txt_caution.cloneNode(true)
        txt_caution_cart.id = 'notfba_cart'
        txt_caution_cart.innerHTML = '* THIS ITEM IS NOT FBA *'
        txt_caution_cart.style.background = 'inherit'
        txt_caution_cart.style.fontSize = 'medium'
        txt_caution_cart.style.margin = '0 0 14px 0'

        if (cart_add != null) {
            cart_add.parentElement.prepend(txt_caution_cart)
        }
    }
}