Archive for the ‘Chrome Extention’ Category

 

データベースサイズを知りたい。。。web sql database | chrome extension html5

4月 10th, 2012

chrome extension の databaseですが openDatabaseに指定するサイズは、制限値ではなくて、初期値?的なもののようで、超えてもエラーも何も出ません・・・ 基本 html5では、5MBを超えるとメッセージが出て、okしたら自動拡張されるようです。 http://html5doctor.com/introducing-web-sql-databases/ とりあえず、今のところサイズを知ることは、出来ないようなので、データを入れるときにデータ容量だけ計算して保存しておこうかと思います。 サイズ取得に成功した方がいましたら教えてください。

Read full article | コメントは受け付けていません。

隠しプロパティ?タブをアクティブにする。 | 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をします。

Read full article | コメントは受け付けていません。

javascript delete , undefined

4月 9th, 2012

objectの要素を削除する。 obj = { prop: 100 }; // 100 console.log( obj.prop ); delete( obj.prop ); // undefined console.log( obj.prop );

Read full article | コメントは受け付けていません。

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 break; case 84: // T break; case 73: // I break; case 77: // m break; } } }, false); shift+のときだけショートカットしてみます。 91はmacでcommandでしたが、metakey = trueになったのでこんな感じで あと入れるとしたらtabとかですかね

Read full article | コメントは受け付けていません。

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

Read full article | コメントは受け付けていません。

message passing | chrome extension

4月 4th, 2012

http://code.google.com/chrome/extensions/messaging.html サイトAのとき http://a.com/ ・backgroundから、サイトAにボタンを追加 ・サイトAでボタンをクリックしたことをbackgroundで取得 content scriptに、クリックしてrequestするスクリプトを追加 http://code.google.com/chrome/extensions/content_scripts.html manifest “content_scripts”: [ { “matches”: ["http://*.a.com/*"], “js”: ["js/jquery-1.7.2.min.js","js/content.js"] } ], js/content.js var grCont = {}; grCont.doClick = function(){ // クリックしたらメセージを送る chrome.extension.sendRequest({greeting: “hello”}, function(response) { console.log(response.farewell);}); }; $(document).ready(function(){ var url = location.href; //ボタンを作る $(‘body’).prepend(“click here“); // ボタンに関数を $(‘#myclick’).click(grCont.doClick); }); background.js に イベントリスナーを入れる chrome.extension.onRequest.addListener( function(request, sender, sendResponse) { console.log(‘onrequest’); […]

Read full article | コメントは受け付けていません。

web sql database | chrome extension

4月 4th, 2012

とりあえず 50 Mとかで開くことが出来るので OK っぽい?です。 ( unlimited ) gr.webdb ={ db : null, init:function(){ gr.webdb.open(); gr.webdb.createTable(); }, open : function() { var dbSize = 50 * 1024 * 1024; // 50MB gr.webdb.db = openDatabase(“gr”, “1.0”, “gr”, dbSize); }, ちょっと触って思ったのは、transactionが非同期なのがなかなか ajaxと同じだけど、普段のsqlのイメージと違うちょっと。

Read full article | コメントは受け付けていません。

localstorage size error ? | chrome extension

4月 4th, 2012

さっきunlimitedのことを書いたばかりですが、localstorageには使えないようです。 ( web sql , app cashのみと書いてありましたが、文字通りダメでした。) DOMException code: 22 message: “QUOTA_EXCEEDED_ERR: DOM Exception 22″ name: “QUOTA_EXCEEDED_ERR” __proto__: DOMException quota exceeded : 容量制限えらー・・・ http://stackoverflow.com/questions/3027142/calculating-usage-of-localstorage-space JSON.stringify(localStorage).lengthで見ると2,500,000 characters.でダメみたいです。 サイズというよりも字数で http://code.google.com/p/chromium/issues/detail?id=58985 UTF-16だから2,500,000文字でダメだとかそんな話をしています。

Read full article | コメントは受け付けていません。

unlimitedStorage over 5MB | chrome extension

4月 4th, 2012

web sql , app cache に5MB以上保存したいとき manifest.jsonにpermissionを追加 http://code.google.com/chrome/extensions/manifest.html#permissions “unlimitedStorage” Provides an unlimited quota for storing HTML5 client-side data, such as databases and local storage files. Without this permission, the extension is limited to 5 MB of local storage. Note: This permission applies only to Web SQL Database and application cache (see issue 58985). Also, it […]

Read full article | コメントは受け付けていません。

Refused to execute inline script because of Content-Security-Policy. | chrome extension

4月 3rd, 2012

chrome extension で manifest version 2にするとインラインスクリプトが使えないとのことで。 * インラインをファイルに分ける。 * onclickとかは、後から付ける。 に変更しました。

Read full article | コメントは受け付けていません。