This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node -v # => v8.1.1 | |
node --harmony -e "r=require,h=r('http');h.createServer((q,s)=>{q.pipe(h.request({...q,...r('url').parse(q.url)},a=>{s.writeHead(a.statusCode,a.headers);a.pipe(s)}))}).listen(8081)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
var socket; | |
$(document).ready(function() { | |
socket = new io.Socket(); | |
socket.connect(); | |
// 接続成功 | |
socket.on('connect', function() { | |
$('#select').show(); | |
$('#status').text('サーバーと接続成功!'); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html><head> | |
<script> | |
var url = 'http://localhost:12000/#receive'; | |
var type; | |
chrome.tabs.onUpdated.addListener(function(id, info, tab) { // タブが更新されたときに呼ばれる | |
if (tab.url.match(url)) { | |
// 命令部分だけを取り出す | |
type = JSON.parse(tab.url.substring(url.length + 1)).type; | |
chrome.tabs.getAllInWindow(null, function(tabs) { | |
for (var i=0; i<tabs.length; i++) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://localhost:12000/#receive | |
↓ { type: 'aaa' } という情報を受信 | |
URLが http://localhost:12000/#receive/{type:'aaa'} となったのち、http://localhost:12000/#receive に戻る |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html><head> | |
<meta charset="utf-8"> | |
<style type="text/css"> | |
html { | |
height: 100%; | |
width: 100%; | |
display: table; | |
} | |
body { | |
height: 100%; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html><head> | |
<script> | |
var url = 'http://localhost:12000/#receive'; | |
var type; | |
chrome.tabs.onUpdated.addListener(function(id, info, tab) { // タブが更新されたときに呼ばれる | |
if (tab.url.match(url)) { | |
// 命令部分だけを取り出す | |
type = JSON.parse(tab.url.substring(url.length + 1)).type; | |
chrome.tabs.getAllInWindow(null, function(tabs) { | |
for (var i=0; i<tabs.length; i++) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var io = require('socket.io'); | |
var express = require('express'); | |
var app = express.createServer(); | |
app.configure(function(){ | |
app.use(express.static(__dirname)); | |
app.use(express.logger()); | |
app.use(app.router); | |
}); |