技術めも

Bookmarklet

Bookmarkletを作ろう(準備編)
https://qiita.com/kanaxx/items/63debe502aacd73c3cb8

google closure compiler
https://closure-compiler.appspot.com/home

javascript:(
    function(){
      title = document.title;
      href = document.location.href;
      canonical = get_canonical();
      console.log('ページタイトル=%s \n href=%s \n カノニカルURL=%s', title, href, canonical);
      alert('ページタイトル:'+title +"\n現在のURL:"+href + "\nカノニカルURL:" + canonical);

      function get_canonical(){
        links = document.getElementsByTagName("link");
        for ( i in links) {
            if (links[i].rel) {
                if (links[i].rel.toLowerCase() == "canonical") {
                    return links[i].href;
                }
            }
        }
        return "";
      }
    }
  )();

Amazon Bookmarklet

https://www.amazon.co.jp/gp/your-account/order-history/

javascript:(function(){function c(){var d="";$("div.a-box-group").each(function(){var a=$(this).find("div.a-box-inner"),b=a.find("div.a-span3 span.value").text(),c=a.find("div.a-row.a-size-base").eq(1).find("span.a-color-secondary.value").text();a=a.find("div.a-size-mini span.value").text();d+=b.trim()+"\t"+c.trim().replace("\uffe5 ","")+"\t"+a.trim()+"\t";$(this).find("div.a-box-inner div.a-fixed-left-grid-inner").each(function(){var a=$(this).find("a.a-link-normal").eq(1).text();d+=a.trim()+"\t"});d+="\n"}); console.log(d)}if("function"!==typeof jQuery){var e=document,b=e.createElement("script");b.src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js";b.onload=c;e.body.appendChild(b)}else c()})();
javascript:(function(){var year="2018";function d(){e(0)}function h(a){var b="";a=jQuery.parseHTML(a);$(a).find("div.a-box-group").each(function(){var a=$(this).find("div.a-box-inner"),c=a.find("div.a-span3 span.value").text(),d=a.find("div.a-row.a-size-base").eq(1).find("span.a-color-secondary.value").text();a=a.find("div.a-size-mini span.value").text();b+=c.trim()+"\t"+d.trim().replace("\uffe5 ","")+"\t"+a.trim()+"\t";$(this).find("div.a-box-inner div.a-fixed-left-grid-inner").each(function(){var a=$(this).find("a.a-link-normal").eq(1).text();
b+=a.trim()+"\t"});b+="\n"});f+=b;return""==b?!1:!0}function e(a){console.log(year+" amazon history load page "+(a+1));jQuery.Deferred();k(a).done(function(b){h(b)?(a+=1,e(a)):console.log(f)})}function k(a){var b=jQuery.Deferred();jQuery.ajax({url:"https://www.amazon.co.jp/gp/css/order-history?digitalOrders=1&unifiedOrders=1&orderFilter=year-"+year+"&startIndex="+10*a,beforeSend:function(a){a.setRequestHeader("X-Requested-With",{toString:function(){return""}})}}).success(function(a){b.resolve(a)}).fail(function(a,
b){console.log("fail",b)});return b.promise()}var f="";if("function"!==typeof jQuery){var g=document,c=g.createElement("script");c.src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js";c.onload=d;g.body.appendChild(c)}else d()})();