72. $ cfx init
$ mkdir firefox-addon-sample
// cfx initは空のディレクトリでのみ実行可能
$ cd firefox-addon-sample
$ cfx init
* lib directory created
* data directory created
* test directory created
* generated jID automatically: *********
* package.json written
* test/test-main.js written
* lib/main.js written
!
Your sample add-on is now ready.
Do "cfx test" to test it and "cfx run" to try it. Have fun!
134. clipboard
var clipboard = require("sdk/clipboard");
clipboard.set("KMC is great!");
var contents = clipboard.get();
//set some HTML
clipboard.set("<marquee>KMC KMC KMC</marquee>", "html");
161. simple-prefs
値を取り出す時は name を使う
"preferences": [{
"name": "somePreference",
"type": "string",
"value": "this is the default string value"
}]
var preferences = require("sdk/simple-prefs").prefs;
// Get
console.log(preferences.somePreference);
// Update
preferences.somePreference = "this is a new value";
package.json
main.js
162. type (1)
bool: <input type='checkbox'>
boolint: checkbox が表示されるが値はT/Fで
はなくて on off の値が利用される
"preferences": [{
"type": "boolint",
"on": "1", // value for true must be string
"off": "2", // value for false must be string
"value": 1
}]