PC版Android Marketで探したアプリをANdroid端末に送る方法を考える。ついでにgoo.glを使うためのマズーなスクリプトのアップデート

アカウントに紐付ければ……は無しで

端末に紐付けられたGoogleのアカウントでログインしておけば遠隔インストール可能なんですけどねw
今回はそれ以外の方法でってことで。

理由としてはまずGoogleにログインし続けない主義だから。
さらに(敢えて)サブ垢しか紐付けて無いし。
まぁ、家だと偶に遠隔インストール使いますけどね。

色々考えて(例:メール、Twitter...)、結果QRコード使うことにしました。
スクリプト拾ってきて「about:〜」なんかに自前でQRコード生成するとかも考えたけど、そういやgoo.glにそういう機能*1があったなぁと思い出したのでそちらを使うことに。*2

Android Marketにgoo.glへのリンクを挿入するSeaHorseスクリプト

アプリ詳細ページを開くと、アプリ名の後ろに"(goo.gl)"というテキストのリンクを挿入します。

↓↓

GooglLinkOnAndroidMarket.user.js

// ==UserScript==
// @name         Goo.gl Link on Android Market
// @author       破楽戸.*
// @include      https://market.android.com/details*
// ==/UserScript==

(function() {
	if(!document.getElementById("GooglLinkOnAndroidMarket")) {
		var h1 = document.getElementsByTagName("h1")[0];
		var q = document.URL.split("?")[1].split("&");
		for(var i = 0; i < q.length; i++) {
			if(q[i].match(/^id=/) != null) {
				var a = document.createElement("a");
				a.id = "GooglLinkOnAndroidMarket";
				a.href = "http://goo.gl/?dummy="+ encodeURIComponent("https://market.android.com/details/?" + q[i]);
				a.innerText = " (goo.gl)";
				a.style.color = "#ffffff";
				h1.appendChild(a);
			}
		}
	}
})();

※下記のスクリプトと組み合わせて使用するので両方入れてね。

Goo.gl向けのスクリプトをアップデート

短縮URIサービスのgoo.glを使うためのマズーなスクリプトで書いてあるうちのSeaHorseスクリプトの方をアップデートしました。
具体的にはiframeでQRコードを挿入するようにした。ついでに短縮URIの詳細情報ページ*3へのリンクもつけた。



// ==UserScript==
// @name         Goo.gl Automatic Pilot
// @author       破楽戸.*
// @include      http://goo.gl/?dummy=*
// @include      http://goo.gl/?url=*
// @type         SleipnirScript
// ==/UserScript==

(function() {

if(location.href.match(/http:\/\/goo\.gl\/\?dummy=/) != null) {
	document.getElementById("shorten").value = decodeURIComponent(location.href.substring(location.href.indexOf("?")+7, location.href.length));
	document.getElementsByTagName("form")[0].submit();
}else if(location.href.match(/http:\/\/goo\.gl\/\?url=/) != null) {
	if(document.getElementById("result").value == "http://goo.gl/...") {
		document.getElementById("result").value = location.href.substring(location.href.indexOf("?")+5, location.href.length);
	}
	document.getElementById("result").setAttribute("onfocus", "javascript:this.select();");
	document.getElementById("shorten_container").style.backgroundColor = "#aaccff";
	document.getElementById("shorten_container").style.border = "1px solid #336699";
	
	var ins = document.getElementById("resolutions");
	var a = document.createElement("a");
	a.href = "http://goo.gl/info/" + location.href.substring(location.href.indexOf("?")+19, location.href.length);
	a.style.display = "block";
	a.innerText = location.href.substring(location.href.indexOf("?")+5, location.href.length) + "+";
	ins.parentNode.insertBefore(a, ins);
	var ifrm = document.createElement("iframe");
	ifrm.src = location.href.substring(location.href.indexOf("?")+5, location.href.length) + ".qr";
	ifrm.width = "160px";
	ifrm.height = "160px";
	ins.parentNode.insertBefore(ifrm, ins);
	
}

}());

Android端末でQRコードを読む際の注意

私の端末に入っているブラウザアプリの中では標準ブラウザ、Dolphin HDだけがAndroid Marketアプリを起動して詳細ページを表示してくれました。
Sleipnir MobileOpera Mobile、Firefox MobileAndroid Marketのページを開いてしまいました。

ということで読み込んだURIを開くブラウザには注意ってことで。

*1:goo.glで短縮したURIの後ろに".qr"付けるだけ

*2:bit.lyにも同様の機能があって".qr"付加でQRコードを含むページを表示、".qrcode"付加でQRコードの画像単体

*3:goo.glで短縮したURIの後ろに"+"付けると飛ぶ