From c0381b9d0737643f5a9fe72a06da929a93549659 Mon Sep 17 00:00:00 2001 From: swfz Date: Thu, 21 Sep 2023 00:12:06 +0900 Subject: [PATCH 1/8] =?UTF-8?q?feat:=20=E8=81=B4=E8=AC=9B=E8=80=85?= =?UTF-8?q?=E3=81=A8=E5=90=8C=E3=81=98=E7=94=BB=E9=9D=A2=E3=81=AEcontent?= =?UTF-8?q?=5Fscript=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- content_script/sakura.ts | 35 +++++++++++++++++++++++++++++++++++ manifest.json | 6 ++++++ 2 files changed, 41 insertions(+) create mode 100644 content_script/sakura.ts diff --git a/content_script/sakura.ts b/content_script/sakura.ts new file mode 100644 index 0000000..29132d2 --- /dev/null +++ b/content_script/sakura.ts @@ -0,0 +1,35 @@ +console.log('loaded google slide comment stream'); + +chrome.runtime.onMessage.addListener((message, sender, sendResponse) => { + console.log('subscribe plant comment when page changed started'); + + const broadcastChannel = new BroadcastChannel('plant_comment_channel'); + + const handleEvent = (event) => { + const textarea = document.querySelector('.punch-ask-question-submit-question-dialog-question-textarea'); + if (textarea === null) { + return + } + textarea.click(); + + const anonimity = document.querySelector('.docs-material-gm-labeled-checkbox-checkbox'); + if (anonimity?.ariaChecked === 'false') { + anonimity.click(); + } + + const inputEvent = new Event('input', { 'bubbles': true, 'cancelable': true }); + textarea.value = event.data; + textarea.dispatchEvent(inputEvent); + + const button = document.querySelector('.punch-ask-question-submit-button') + + const mousedownEvent = new MouseEvent("mousedown", { bubbles: true, cancelable: true, view: window, button: 0 }); + button?.dispatchEvent(mousedownEvent); + + const mouseupEvent = new MouseEvent("mouseup", { bubbles: true, cancelable: true, view: window, button: 0 }); + button?.dispatchEvent(mouseupEvent); + }; + + broadcastChannel.onmessage = handleEvent; + sendResponse({ screenType: 'usertool', message: 'A listener has been added to the usertool.' }); +}); \ No newline at end of file diff --git a/manifest.json b/manifest.json index 77942a4..9fdb26e 100644 --- a/manifest.json +++ b/manifest.json @@ -11,8 +11,14 @@ "matches": ["https://docs.google.com/presentation/d/*/edit"], "match_about_blank": true, "js": ["content_script/stream.ts", "content_script/presenter_subscribe.ts"] + }, + { + "matches": ["https://docs.google.com/presentation/d/e/*/askquestion?*"], + "match_about_blank": true, + "js": ["content_script/sakura.ts"] } ], + "options_page": "options.html", "action": { "default_popup": "index.html", "default_icon": { From 35056f6674ffb6d92e2e5bd5a5f57bc241b99117 Mon Sep 17 00:00:00 2001 From: swfz Date: Thu, 21 Sep 2023 00:12:27 +0900 Subject: [PATCH 2/8] chore: add log --- content_script/presenter_subscribe.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/content_script/presenter_subscribe.ts b/content_script/presenter_subscribe.ts index e10f1bb..d77dc3d 100644 --- a/content_script/presenter_subscribe.ts +++ b/content_script/presenter_subscribe.ts @@ -1,3 +1,5 @@ +console.log('loaded google slide comment stream'); + const subscribeComments = (observeElement, sendResponse) => { const broadcastChannel = new BroadcastChannel('comment_channel'); From 197761fbf91d70913765b879be375a80cb06acf6 Mon Sep 17 00:00:00 2001 From: swfz Date: Thu, 21 Sep 2023 00:21:42 +0900 Subject: [PATCH 3/8] =?UTF-8?q?feat:=20=E8=A8=AD=E5=AE=9A=E7=94=BB?= =?UTF-8?q?=E9=9D=A2=E3=81=AE=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- options.html | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ options.js | 20 ++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 options.html create mode 100644 options.js diff --git a/options.html b/options.html new file mode 100644 index 0000000..0b9a2c3 --- /dev/null +++ b/options.html @@ -0,0 +1,50 @@ + + + + + + + +
+

Comment setting for preparation

+
+
+

+ This function is used to play a predefined comment at a predetermined timing. +

+

+ The key is the slide number +

+

+ When you transition to the target slide number, a `comment` message is automatically posted after `seconds` seconds of each line +

+

+ To use this feature, the extension must also Start on the screen where the audience posts comments in the User Tools +

+
+ +
+
Configuration Structure(e.g.)
+
+      
+{
+  "3": [
+    {"seconds": 0.5, "comment": "looks good"},
+    {"seconds": 1, "comment": "cooooooooooool!!!!"}
+  ],
+  "4": [
+    {"seconds": 2, "comment": "wow"}
+  ]
+}
+      
+    
+
+ +
+
+ +
+ + + + diff --git a/options.js b/options.js new file mode 100644 index 0000000..3499514 --- /dev/null +++ b/options.js @@ -0,0 +1,20 @@ +function options() { + + const textarea = document.getElementById('sakura'); + chrome.storage.sync.get(['sakura'], ({sakura}) => { + if (sakura) { + textarea.value = JSON.stringify(sakura, null, 2); + } + }); + + const handleSave = function(event) { + const sakuraOption = document.querySelector('textarea[id="sakura"]').value; + const json = JSON.parse(sakuraOption); + chrome.storage.sync.set({sakura: json}); + } + + const saveButton = document.getElementById('save'); + saveButton.addEventListener('click', handleSave); +} + +options(); \ No newline at end of file From afc634062e5bffaa6fb66d226b2d5bd2383a9b73 Mon Sep 17 00:00:00 2001 From: swfz Date: Thu, 21 Sep 2023 00:22:49 +0900 Subject: [PATCH 4/8] =?UTF-8?q?feat:=20=E3=82=B9=E3=83=A9=E3=82=A4?= =?UTF-8?q?=E3=83=89=E5=81=B4=E3=81=A7=E3=83=9A=E3=83=BC=E3=82=B8=E5=A4=89?= =?UTF-8?q?=E6=9B=B4=E3=82=92=E3=82=AD=E3=83=A3=E3=83=83=E3=83=81=E3=81=99?= =?UTF-8?q?=E3=82=8B=E3=81=9F=E3=82=81=E3=81=AE=E5=87=A6=E7=90=86=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- content_script/stream.ts | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/content_script/stream.ts b/content_script/stream.ts index 519b049..340e052 100644 --- a/content_script/stream.ts +++ b/content_script/stream.ts @@ -26,6 +26,43 @@ const clapElementStyle = (bottom, right) => { }; }; +const addSubscribePageNumber = () => { + const broadcastChannel = new BroadcastChannel('plant_comment_channel'); + const iframeElement: HTMLIFrameElement = document.querySelector('.punch-present-iframe'); + + if (iframeElement === null) { + return; + } + const observeElement = iframeElement.contentWindow.document.querySelector('.docs-material-menu-button-flat-default-caption'); + + if (observeElement === null) { + console.log('not exist observe element'); + return; + } + + const observer = new MutationObserver(function (records) { + const added = records.at(-1)?.addedNodes[0]?.textContent; + const removed = records[0]?.removedNodes[0]?.textContent; + + if (added && removed && added > removed) { + chrome.storage.sync.get(['sakura'], ({sakura}) => { + const plantCommentRows = sakura[added]; + + if (plantCommentRows !== undefined) { + plantCommentRows.forEach((commentRow) => { + setTimeout(() => { + broadcastChannel.postMessage(commentRow.comment); + }, commentRow.seconds * 1000); + }); + } + }) + } + }); + + observer.observe(observeElement, { subtree: true, childList: true }); +} + + chrome.runtime.onMessage.addListener((message, sender, sendResponse) => { const iframeElement: HTMLIFrameElement = document.querySelector('.punch-present-iframe'); @@ -127,5 +164,6 @@ chrome.runtime.onMessage.addListener((message, sender, sendResponse) => { broadcastChannel.onmessage = handleEvent; }); + addSubscribePageNumber(); sendResponse({ screenType: 'slide', message: 'A listener has been added to the SLIDE side.' }); }); From 2e74603dbbba1b74740b1310f00796288c04d4f8 Mon Sep 17 00:00:00 2001 From: swfz Date: Thu, 21 Sep 2023 00:49:32 +0900 Subject: [PATCH 5/8] feat: use optional checkbox --- content_script/sakura.ts | 48 ++++++++++++++++++++++------------------ src/App.tsx | 8 +++++++ 2 files changed, 34 insertions(+), 22 deletions(-) diff --git a/content_script/sakura.ts b/content_script/sakura.ts index 29132d2..284a168 100644 --- a/content_script/sakura.ts +++ b/content_script/sakura.ts @@ -6,28 +6,32 @@ chrome.runtime.onMessage.addListener((message, sender, sendResponse) => { const broadcastChannel = new BroadcastChannel('plant_comment_channel'); const handleEvent = (event) => { - const textarea = document.querySelector('.punch-ask-question-submit-question-dialog-question-textarea'); - if (textarea === null) { - return - } - textarea.click(); - - const anonimity = document.querySelector('.docs-material-gm-labeled-checkbox-checkbox'); - if (anonimity?.ariaChecked === 'false') { - anonimity.click(); - } - - const inputEvent = new Event('input', { 'bubbles': true, 'cancelable': true }); - textarea.value = event.data; - textarea.dispatchEvent(inputEvent); - - const button = document.querySelector('.punch-ask-question-submit-button') - - const mousedownEvent = new MouseEvent("mousedown", { bubbles: true, cancelable: true, view: window, button: 0 }); - button?.dispatchEvent(mousedownEvent); - - const mouseupEvent = new MouseEvent("mouseup", { bubbles: true, cancelable: true, view: window, button: 0 }); - button?.dispatchEvent(mouseupEvent); + chrome.storage.sync.get(['config'], ({ config }) => { + if(config.plant) { + const textarea = document.querySelector('.punch-ask-question-submit-question-dialog-question-textarea'); + if (textarea === null) { + return + } + textarea.click(); + + const anonimity = document.querySelector('.docs-material-gm-labeled-checkbox-checkbox'); + if (anonimity?.ariaChecked === 'false') { + anonimity.click(); + } + + const inputEvent = new Event('input', { 'bubbles': true, 'cancelable': true }); + textarea.value = event.data; + textarea.dispatchEvent(inputEvent); + + const button = document.querySelector('.punch-ask-question-submit-button') + + const mousedownEvent = new MouseEvent("mousedown", { bubbles: true, cancelable: true, view: window, button: 0 }); + button?.dispatchEvent(mousedownEvent); + + const mouseupEvent = new MouseEvent("mouseup", { bubbles: true, cancelable: true, view: window, button: 0 }); + button?.dispatchEvent(mouseupEvent); + } + }); }; broadcastChannel.onmessage = handleEvent; diff --git a/src/App.tsx b/src/App.tsx index e91694a..8fc7a31 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -7,6 +7,7 @@ type Config = { speedPx?: number; sizePx?: number; clap?: string; + plant?: boolean; }; function App() { @@ -33,6 +34,9 @@ function App() { const handleClapChange = (event: ChangeEvent) => { setConfig((prev) => ({ ...prev, clap: event.target.value })); }; + const handlePlantChange = (event: ChangeEvent) => { + setConfig((prev) => ({ ...prev, plant: event.target.checked })); + }; const handleStart = async () => { const [tab] = await chrome.tabs.query({ active: true, currentWindow: true }); @@ -135,7 +139,11 @@ function App() { ); })} +
+ + +
From abf83194cb8972be4010f9a60022f5a15a41bbea Mon Sep 17 00:00:00 2001 From: swfz Date: Thu, 21 Sep 2023 00:51:26 +0900 Subject: [PATCH 6/8] chore: change id --- src/App.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 8fc7a31..69d75a0 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -142,8 +142,8 @@ function App() {
- - + +
From 3d82c88617b8690a6efa3f603948cf5f72344aa5 Mon Sep 17 00:00:00 2001 From: swfz Date: Thu, 21 Sep 2023 01:15:49 +0900 Subject: [PATCH 7/8] style: table layout --- src/App.css | 20 +++++++++++ src/App.tsx | 100 +++++++++++++++++++++++++++++++--------------------- 2 files changed, 80 insertions(+), 40 deletions(-) diff --git a/src/App.css b/src/App.css index 0a63e4e..b96f070 100644 --- a/src/App.css +++ b/src/App.css @@ -64,3 +64,23 @@ label { height: 100px; vertical-align: top; } + +.pseudo-table { + display: table; + width: 100%; + border-collapse: collapse; +} + +.pseudo-row { + display: table-row; +} + +.pseudo-cell { + display: table-cell; + padding: 5px 1px; + border: 1px solid #999; +} + +.pseudo-cell:first-child { + width: 60%; +} \ No newline at end of file diff --git a/src/App.tsx b/src/App.tsx index 69d75a0..585735b 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -103,47 +103,67 @@ function App() {

GoogleSlide Comment Stream

-

スライド側とユーザーツール側両方で「Start」をクリックしてください

+

Click "Start" on both the slide side and the presenter user tools side

- - -
- - - -
- - - -
- - - -
- - - - -
- - - +
+
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+
From 79f8691837f75d8ecd5ccdecc96efe7cca5ad3ec Mon Sep 17 00:00:00 2001 From: swfz Date: Thu, 21 Sep 2023 01:34:20 +0900 Subject: [PATCH 8/8] =?UTF-8?q?chore:=201=E7=94=BB=E9=9D=A2=E3=81=AB?= =?UTF-8?q?=E5=8F=8E=E3=81=BE=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E3=81=97?= =?UTF-8?q?=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.css | 13 ------------- src/App.tsx | 2 +- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/src/App.css b/src/App.css index b96f070..a395a48 100644 --- a/src/App.css +++ b/src/App.css @@ -25,19 +25,6 @@ color: white; } -.App-link { - color: #61dafb; -} - -@keyframes App-logo-spin { - from { - transform: rotate(0deg); - } - to { - transform: rotate(360deg); - } -} - button { font-size: calc(10px + 2vmin); } diff --git a/src/App.tsx b/src/App.tsx index 585735b..d7bbfde 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -102,7 +102,7 @@ function App() { return (
-

GoogleSlide Comment Stream

+

GoogleSlide Comment Stream

Click "Start" on both the slide side and the presenter user tools side