å¨å® ã¯ã¼ã¯ä¸ã«å®¶æã«ä¼è°ä¸ã ã¨ã¢ãã¼ã«ããã©ã¤ãããã¯
ç¾å¨å¨å® ã¯ã¼ã¯ä¸ãªããã ãã©, 家æã«ãã¼ãã£ã³ã°ä¸ã§ãã¨ã¢ãã¼ã«ããããã«, ãã¼ãã£ã³ã°ã¯ããæãã®ã©ã³ããç¹ç¯ãããããã¦ããã
ãã ãã¼ãã£ã³ã°å§ã¾ã/çµãã£ãã¨ãã«æåã§ON/OFFããã®é¢åãªã®ã§, èªååãã¦ã¿ãã
äºåæºå
ã¾ãã¯é éã§æä½ã§ããããã«, ã¹ãã¼ããã©ã°ãç¨æã
TP-Link ã®ãã¤ãå®ãã®ã§ããã«ãããIFTTT 対å¿ãã¦ãããªãå¥ãªãã¤ã§ããããããAmazon ã§ããã£ããéæ»å±ããã®ã§, Webhook ã®è¨å®ã㦠HTTP request æãã¦ç¹ãããæ¶ãããããã®ã確èªã
Chrome æ¡å¼µãä½ã
å¼ç¤¾ã§ã¯ãã¼ãã£ã³ã°ã« Google Meets ã使ç¨ãã¦ããã®ã§, meet.google.com
ãã¡ã¤ã³ãéããã¨ãã«ã©ã³ããç¹ç¯, éãããæ¶ç¯, ã¿ããã«ããããä»åã¯ããç¨ã® Chrome æ¡å¼µãä½ã£ããã©ããã chrome.tabs API ã使ãã°ç¾å¨éãã¦ããã¿ãä¸è¦§ã¨ããåå¾ã§ããã®ã§, ããã使ã£ã¦ã¿ãã
manifes.json ã¯ãããªæãã
{ "manifest_version": 2, "name": "Google Meets éãããã©ã³ãã¤ãããã", "description": "Google Meets éãããã©ã³ãã¤ãã¦ããã¾ã", "version": "1.0", "background": { "scripts": ["event.js"], "persistent": false }, "permissions": ["tabs", "*://maker.ifttt.com/*"] }
permissions ã« ifttt ã®ãã¡ã¤ã³ãæå®ãã¦ããã®ã¯, ããããªã㨠CORS ã¨ã©ã¼ã§æãããããããã¨ã¯é©å½ã« js æ¬ä½ãç¨æã
const googleMeetsDomain = "meet.google.com"; const turnOnUrl = "https://maker.ifttt.com/hogehogehogel"; const turnOffUrl = "https://maker.ifttt.com/fugafugafuga"; var isTurnOn = 0; function watchTabs() { chrome.tabs.query({}, (tabs) => { const isOpeningMeets = tabs.some((tab) => { return tab.url.match(/meet.google.com/); }); if (isOpeningMeets && !isTurnOn) { request(turnOnUrl); isTurnOn = 1; } if (!isOpeningMeets && isTurnOn) { request(turnOffUrl); isTurnOn = 0; } }); } function request(url) { var req = new XMLHttpRequest(); req.open("GET", url); req.send(); } chrome.tabs.onUpdated.addListener(watchTabs); chrome.tabs.onRemoved.addListener(watchTabs);
chrome.tabs.query
ã§å
¨ã¿ãã® url ããªãã¦, Meets ã® url ãå«ã¾ãã¦ããã° ON, å«ã¾ãã¦ããªããªã OFF ããæããonRemoved
ã¯ã¿ããéããã¨ããonUpdated
ã¯ã¿ããæ´æ°ãããã¨ãã®ã¤ãã³ããChrome èªä½ãéããã¨ãã¯ããã ã¨ãã¡ã ãã©, ããã¾ãå°ã£ã¦ãªãã®ã§ã¾ãããã, ã¨ãªã£ã¦ããã
å®éã®æ§å
Meets ã ããããªãã¦, ä¾ãã° youtube ã§ãæ©å«ãªåç»ãæµããã¨ãã«ãã©ã¼ãã¼ã«ãç¹ç¯ããã¨ã, ä»äºä¸ã« Twitter ãè¦å§ãããå¹ãç¢ãé£ãã§ãã, ã¿ãããªãã¨ã«å¿ç¨ãå¹ãããã