コトバノウタカタ

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

Amazon Prime 終了チェック16

またちょっとページ仕様変わってるので。

javascript: var d = document;
dv = d.getElementsByClassName('D0Lu_p');
var cnt = dv.length;
var cnttg = document.createElement('div');
cnttg.textContent = cnt;
d.getElementsByClassName('_3aE6se')[0].appendChild(cnttg);
for (i = 0;
    i < dv.length;
    i++) {
        aa = dv[i].getElementsByTagName('img')[0];
    nm = aa.getAttribute('alt');
    ln = 'https://www.amazon.co.jp/s/ref=nb_sb_noss?__mk_ja_JP=カタカナ&url=node%3D4217521051&field-keywords=' + encodeURIComponent(nm);
    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) {
            rf = this.responseXML.getElementsByClassName('a-section a-spacing-base a-spacing-top-medium');
            hit = false;
            if (rf.length == 0) {
                ls = this.responseXML.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-line-clamp-4');
                        if (h5.length > 0) {
                            tnm = h5[0].textContent.trim();
                            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);
}
;