AndroidHtml for Play

  • /*
     * @title AndroidHtml for Play
     * @description Androidマーケットで実行すると、アイコンやQRコード生成を行います。出力文字列は好きなようにカスタマイズしてください。
     * @include https://market.android.com
     * @include http://market.android.com
     * @license MIT License
     * @require jquery
     */
    (function () {
    
    	var url = document.location.href;
    	if (url.search(/details/) != -1) {
    		// パッケージ名取得(未使用)
    		/*
    		 url.match(/play.google.com.*?id=([a-zA-Z0-9_\-\.!~\*\|]+)/);
    		 var pname = RegExp.$1;
    		 */
    
    		// QRコードURL(未使用 アプリのみ使用可能) ※要パッケージ名 pname
    		//var qrcode = 'http://chart.apis.google.com/chart?chs=150x150&cht=qr&chld=l0&chl=market://details?id=' + pname;
    
    		// アプリ名
    		var appname = $(".document-title").find('div').html();
    		appname = appname.trim();
    
    		// 概要(未使用)
    		/*
    		 var description = $(".app-orig-desc").html();
    		 description = description.replace(/<.+?>/g, "");
    		 // 100文字でカット
    		 description = description.substr(0, 100) + '…';
    		 */
    
    		// サプライヤー
    		var supplier = $('.document-subtitle').html();
    
    		// 価格
    		var price = $('meta[itemprop=price]').attr('content');
    		if (price == null) price = '無料';
    
    		// アイコンURL
    		var icon = $('.cover-container img').attr('src');
    		// chrome の場合 webp 形式なので png にする
    		if (icon.slice(-3) == '-rw') icon = icon.replace('-rw', '');
    
    		// 評価件数・平均点
    		var review = $('.reviews-num').html();
    		var star;
    
    		if (review == null) {
    			review = 0;
    			star = 'アプリの評価はまだされていません。'
    		} else {
    			star = $('.score').html();
    		}
    
    		// 出力用変数
    		var coverStyle = 'style="margin-left:-159px;float:left;width:150px;height:150px;border:none;"';
    
    		// 出力用文字列整形
    		var str;
    		str = '<div class="bookmarklet androidhtml" style="margin:0;">' + '\n';
    		str += '<div style="margin-left:159px;">' + '\n';
    		str += '<a href="' + url + '" target="_blank" style="text-decoration:none;">';
    		str += '<img class="cover-image" src="' + icon + '" ' + coverStyle + ' alt="' + appname + '" />';
    		str += '<strong style="font-size:1.2em;">' + appname + '</strong>';
    		str += '</a>' + '\n';
    		str += '<div class="supplier">制作: ' + '<span>' + supplier + '</span></div>' + '\n';
    		str += '<div class="price">価格: ' + '<span>' + price + '</span></div>' + '\n';
    		str += '<div class="review">平均評価: ' + '<span>' + star + '(合計 ' + review + ' 件)' + '</span></div>' + '\n';
    		// 概要(未使用)
    		//str += '<p class="description">' + description + '</p>' + '\n';
    		// QRコード(未使用 アプリのみ使用可能)
    		//str += '<img src="' + qrcode + '" style="border:none;" alt="' + appname + ' QRコード" />';
    		str += '</div>' + '\n';
    		str += '</div>' + '\n' + '<div style="clear: both"></div>' + '\n';
    
    		window.prompt('これを貼付ける', str);
    	}
    
    })();
    
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2013/12/03 18:15:48 - 2013-12-03
  2. 2013/12/03 18:14:34 - 2013-12-03
  3. 2013/12/03 18:14:27 - 2013-12-03