コトバノウタカタ

よしなしごとをつらつらとつづるばしょ。

Amazon終了確認19

javascript: var d = document;
dv = d.getElementsByClassName('D0Lu_p');
var cnt = dv.length;
var cnttg = document.createElement('div');
cnttg.textContent = cnt;
d.getElementsByClassName('_vfqY6')[0].appendChild(cnttg);
for (i = 0;
    i < dv.length;
    i++) {
        aa = dv[i].getElementsByTagName('img')[0];
    nm = aa.getAttribute('alt');
    asin = dv[i].firstElementChild.getAttribute("data-automation-id").substr(8);
    ;
    ln = 'https://www.amazon.co.jp/s/ref=nb_sb_noss?__mk_ja_JP=カタカナ&url=node%3D4217521051&field-keywords=' + asin;
    var req = new XMLHttpRequest();
    rm = dv[i].getElementsByClassName('_1Opa2_')[0];
    req.rm = dv[i];
    req.ln = ln;
    req.nnm = nm;
    req.onreadystatechange = function () {
        if (this.readyState == 4 && this.status == 200) {
            x = this.responseXML;
            r3 = x.getElementsByClassName('a-size-medium a-spacing-none');
            hit = false;
            if (r3.length == 0) {
                ls = x.getElementsByClassName('rush-component s-latency-cf-section');
                if (ls.length > 0) {
                    hit = true;
                    chs = ls[0].children;
                    en = '';
                    for (chi = 0;
                        chi < chs.length;
                        chi++) {
                        ch = chs[chi];
                        h5 = ch.getElementsByClassName('s-image');
                        if (h5.length > 0) {
                            tnm = h5[0].getAttribute('alt');
                            console.log(tnm + '/' + this.nnm);
                            if (tnm == this.nnm) {
                                en = '終了確認';

                            }

                        }

                    }
                    if (en != '') {
                        a = d.createElement('a');
                        a.href = this.ln;
                        a.textContent = en;
                        a.setAttribute('target', '_blank');
                        dd = d.createElement('div');
                        a.setAttribute('style', 'float:right');
                        dd.appendChild(a);
                        this.rm.appendChild(dd);
                        hit = true;

                    }
                    else {
                        this.rm.style.display = 'none';

                    }
                }
            }
            if (hit == false) {
                this.rm.style.display = 'none';

            }
            cnt--;
            cnttg.textContent = cnt;
        }

    }
        ;
    req.open('GET', ln, true);
    req.responseType = "document";
    req.send(null);

}
;