Skip to content

Instantly share code, notes, and snippets.

@osamum
osamum / MSEdge_extension_browserActionSample_popup.html
Last active October 31, 2016 01:59
Sample popup.html of MS Edge browserAction extension.
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
a {color: #3399FF;}
a:hover {color: #FF6600;}
</style>
</head>
@osamum
osamum / MSEdge_extension_browserActionSample_manifest.json
Last active October 26, 2016 07:36
Sample manifest.json of MSEdge browserAction extension
{
"name": "MSEdge browserAction sample",
"author": "(Your name write down here.)",
"version": "0.1",
"manifest_version": 2,
"description": "マイクロソフト Edge 拡張のサンプル(browserAction)",
"browser_action": {
"default_icon": {
"19": "icon/e-19.png"
},
@osamum
osamum / my1st_extension_background.js
Last active November 16, 2016 05:37
Sample code of Edge extension's manifest file for monoe's blog.
//Edge の名前空間(browser) がなけれぱ chrome の名前空間を使用する
var browser = browser||chrome;
//コンテキストメニューに拡張のメニューを追加
browser.contextMenus.create({
id: 'menu_1st_extension',
title: '"%s"を取得', //%s は選択している文字列で置き換わる
contexts: ['selection'], //選択しているときのみメニューに表示される
onclick: (info, tab)=>{ //クリックされた際のアクション
alert(info.selectionText);
@osamum
osamum / my1st_extension_manifest.json
Last active November 16, 2016 05:38
Sample setting of Edge extension's manifest file for monoe's blog.
{
"name": "はじめての拡張",
"author": "(Your name write down here.)",
"version": "0.1",
"description": "選択された文字を返しますよ",
"background": {
"scripts": ["background.js"],
"persistent": true
},
"permissions": [
@osamum
osamum / generator-yield_promise.js
Created June 30, 2016 08:21
Sample of JavaScript's asynchronous processing (generator/yield) : de:code2016 - ARC-003
//Generator を呼び出す
var gen = stepper();
//Promise を使用して Generator の next メソッドを実行する
gen.next().value.then(()=>{
return gen.next().value;
}).then(()=>{
return gen.next().value;
});
@osamum
osamum / generator-yield_async.js
Last active June 30, 2016 08:31
Sample of JavaScript's asynchronous processing (generator/yield) : de:code2016 - ARC-003
//generator と yield を使用した非同期制御
var gen = stepper();
gen.next()
//関数 stepper を generator として宣言
function *stepper(){
yield setTimeout(()=>{
echo_arg('A');
//生成された iterator の next メソッドをイベントハンドラ内で実行し次の処理に遷移させる
gen.next();
//非同期実行のためコードの順番ではなく、
//コンソールには C, B, A の順番で出力される
setTimeout('echo_arg("A")',3000);
setTimeout('echo_arg("B")',2000);
setTimeout('echo_arg("C")',1000);
@osamum
osamum / nfc-detect_sample.html
Created June 2, 2016 07:10
Sample code of UWP's detect NFC device for hosted web app.
<!DOCTYPE html>
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>NFC Divice detect sample</title>
<script>
window.onload = function () {
var status = document.getElementById('status');
//Windows Runtime が検出されたら
if (typeof Windows !=='undefined') {
@osamum
osamum / cssFilter.html
Last active May 31, 2016 07:18
Sample code of CSS3's API
<!DOCTYPE html>
<html lang="ja" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<style>
option {
font-size: 20px;
}
select {
@osamum
osamum / gamepad.html
Created May 31, 2016 04:54
Sample code of HTML5's Gamepad API
<!DOCTYPE html>
<html lang="ja" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>HTML5 Gamepad API Sample</title>
<script>
var displayDiv = null;
//ゲームパッドと操作の検出