追è¨
å ¬éãã¾ããï¼
ð ð ð
以åä½æãããこちらのブックマークレットã
ãã¾ã§ãæç¨ãã¦ãã¾ãã
å
æ¥ãGoolge Chromeの拡張機能の作り方を調べたã¨ãããé常ã«ç°¡åã ã£ãã®ã§ç§»æ¤ãã¦ã¿ããã¨ã«ãã¾ãããããã«ã¯åå¼·ã®ããã«å
¬éã¾ã§ããåã£ã¦ã¿ããã¨æãã¾ãã
ã½ã¼ã¹ã³ã¼ã
manifest.json
{ "name": "google-calendar-screenshot", "version": "1.0", "manifest_version": 3, "description": "Googleã«ã¬ã³ãã¼ã®äºå®åãé ãã¦ããã¹ã¯ãªã¼ã³ã·ã§ãããæ®å½±ãã¾ã", "icons": { "16": "icon/16.png", "48": "icon/48.png", "128": "icon/128.png" }, "permissions": ["activeTab", "scripting"], "background": { "service_worker": "background.js" }, "action": { "default_title": "google-calendar-screenshot", "default_icon": "icon/16.png" } }
ä»åã¯ãç³è«ã¾ã§ãã¦ã¿ããã¨æã£ãã®ã§ãdescriptionãiconsã追å ãã¾ããã
background.js
chrome.action.onClicked.addListener((tab) => { chrome.scripting.executeScript({ target: { tabId: tab.id }, files: ['html2canvas.min.js', 'main.js'], }); });
filesãè¤æ°ãã¡ã¤ã«ã«ãªãã¾ããã
main.js
(() => { if (/https:\/\/calendar.google.com\/calendar/.test(location.href)) { [].slice.call(document.querySelectorAll('[role="button"] [aria-hidden="true"] > :first-child')).forEach((elm) => { elm.innerHTML = 'äºå®ãã' }); html2canvas(document.querySelector('[data-view-heading]')).then((canvas) => { downloadImage(canvas.toDataURL()); }); function downloadImage(dataUrl) { const name = 'calendar.png'; const a = document.createElement('a'); a.href = dataUrl; a.download = name; a.click(); } } else { window.open('https://calendar.google.com/calendar/'); } })();
以前のコードã¨ã®éãã¨ãã¦ã¯ã
- Googleã«ã¬ã³ãã¼ä»¥å¤ã§å®è¡ããæã®æåã追å ð Googleã«ã¬ã³ãã¼ãéãããã«ãã
- html2canvas.jsã®èªã¿è¾¼ã¿æ¹ãå¤æ´ ð CDNããã§ã¯ãªããbackground.jsã®filesããèªã¿è¾¼ãããã«ãã
ã®2ç¹ã§ãã
移æ¤èªä½ã¯ãã¾ã£ãããã£ã¦ç°¡åã ã£ãã®ã§ãããã¢ã¤ã³ã³ãä½ã£ãããã¹ã¯ãªã¼ã³ã·ã§ãããç¨æããã®ã«ããæéããããã¾ããã
ä¸å¿ãç¾å¨å
¬éã®ç³è«ä¸ã§ãã
ç³è«ãéã£ãããç³è«æ¹æ³ãã¾ã¨ãããã¨æãã¾ãã
ð ð ð