chrome extensionを早く更新したいので、起動オプションを。for mac
4月 25th, 2012
本番にアップしてもすぐに更新できないので、chromeにオプションを付けて起動して一回更新してみる
オプションの付け方は、こんな感じで、1は1分なので、1分前の更新を反映と言う感じでしょうか?
open /Applications/Google\ Chrome.app --args --extensions-update-frequency=1
( windows : chrome.exe --extensions-update-frequency=1
更新されたら、オプション無しで、再起動します。
chrome webstore テストアカウントに公開した後、一般公開する方法 | chrome extension
4月 17th, 2012
https://developers.google.com/chrome/web-store/docs/publish#testaccounts
Note: To publish to the world after publishing to test accounts, you first need to unpublish the app.
一度非公開にする。
Refused to evaluate script because of Content-Security-Policy. | chrome extension
4月 15th, 2012
setTimeout で
Refused to evaluate script because of Content-Security-Policy.
のエラーメッセージ。
setTimeoutをどうやって表現するかと
と思っていたら、ただ書き間違えていただけでした・・・
evalは使えませんが、普通に書く分には問題ないようです。
javascript closure compiler
4月 15th, 2012
複数ファイルを複数ファイルに出来ないのかな・・・?と思い。
compilerをダウンロード
https://developers.google.com/closure/compiler/
$ cd compiler-latest/
COPYING README compiler.jar
複数ファイルを一つにするには、READMEに書いてある通り
java -jar compiler.jar --js=in1.js --js=in2.js … --js_output_file=out.js
.js:55: WARNING - Suspicious code. This code lacks side-effects. Is there a bug?
reutrn;
普通に使うとエラー検出も出来て便利です。
levelを変更してみる
java -jar ../../compiler-latest/compiler.jar [...]
ajaxのhttp headerを書き換える。webrequest API | chrome extension
4月 13th, 2012
普通にxhrを弄る場合は
http://www.w3.org/TR/XMLHttpRequest/
http://www.w3.org/TR/XMLHttpRequest/#the-setrequestheader-method
mimetypeなどは
beforeSend: function(xhr){
xhr.overrideMimeType(”text/plain;charset=Shift_JIS”); // A
xhr.setRequestHeader(”Content-type”,”text/plain;charset=Shift_JIS”); // B
},
はAかBで更新できたのですが、この辺はダメで
Accept-Charset
Accept-Encoding
Access-Control-Request-Headers
Access-Control-Request-Method
Connection
Content-Length
Cookie
Cookie2
Content-Transfer-Encoding
Date
Expect
Host
Keep-Alive
Origin
Referer
TE
Trailer
Transfer-Encoding
Upgrade
User-Agent
Via
さてどうしようかと webRequest API の登場です。
http://code.google.com/chrome/extensions/trunk/webRequest.html#event-onBeforeSendHeaders
* onBeforeSendHeaders (optionally synchronous)
Fires when a request is about to occur and the initial headers have been prepared. The event is intended to [...]
データベースサイズを知りたい。。。web sql database | chrome extension html5
4月 10th, 2012
chrome extension の databaseですが
openDatabaseに指定するサイズは、制限値ではなくて、初期値?的なもののようで、超えてもエラーも何も出ません・・・
基本 html5では、5MBを超えるとメッセージが出て、okしたら自動拡張されるようです。
http://html5doctor.com/introducing-web-sql-databases/
とりあえず、今のところサイズを知ることは、出来ないようなので、データを入れるときにデータ容量だけ計算して保存しておこうかと思います。
サイズ取得に成功した方がいましたら教えてください。
隠しプロパティ?タブをアクティブにする。 | chrome extension
4月 10th, 2012
content scriptからデータを渡して、既存のタブをアクティブに
開いているタブをアクティブにする方法が分からなかったのですが、なんとか
http://code.google.com/chrome/extensions/tabs.html#method-update
ここをみると
update で active:true くらいしか無いのですが
selected というプロパティが存在していると
chrome.tabs.update( grBk.menu.tab.id, {selected:true}, function(tab){});
これで行けました!
content scriptからbackgroundを呼んで、background で このupdateをします。
javascript delete , undefined
4月 9th, 2012
objectの要素を削除する。
obj = {
prop: 100
};
// 100
console.log( obj.prop );
delete( obj.prop );
// undefined
console.log( obj.prop );
shortcut with keydown event keycode | chrome extension
4月 9th, 2012
ショートカットメニューを付けようと
key event propertiesを見ると
http://www.quirksmode.org/dom/w3c_events.html
altKey, ctrlKey, shiftKey, metaKeyがあるのでこの辺と組み合わせて。
window.addEventListener(’keydown’, function(e) {
if (!e.ctrlKey && !e.altKey && !e.metaKey && e.shiftKey ){
switch( e.keyCode ){
case 72: // H
[...]
during tabs.executeScript: Cannot access contents of url | chrome extension
4月 8th, 2012
extensions/schema_generated_bindings.js:82
Error during tabs.executeScript: Cannot access contents of url “chrome-extension://myextensionId000000000000000/menu.html”. Extension manifest must request permission to access this host.
backgroundからexecuteScriptでローカルファイルのスクリプトを実行できない。
http://code.google.com/p/chromium/issues/detail?id=30756
manifest.jsonのpermissionで設定しているhttp://*/*に入っているURLは以外はダメ。( chrome-extension://的な設定は出来ないので。
出来ないので、menu.html側にイベントリスナーを書いて、backgroundでpostmessageする。
postmessageの記事はこちら
http://blog.bbtune.com/archives/1685/message-passing-chrome-extension