-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #152 from swfz/feature/sakura-comment
さくらコメント設定機能
- Loading branch information
Showing
8 changed files
with
240 additions
and
50 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
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) => { | ||
chrome.storage.sync.get(['config'], ({ config }) => { | ||
if(config.plant) { | ||
const textarea = document.querySelector<HTMLTextAreaElement>('.punch-ask-question-submit-question-dialog-question-textarea'); | ||
if (textarea === null) { | ||
return | ||
} | ||
textarea.click(); | ||
|
||
const anonimity = document.querySelector<HTMLInputElement>('.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.' }); | ||
}); |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<link rel="stylesheet" href="button.css"> | ||
</head> | ||
<body> | ||
<div> | ||
<h2>Comment setting for preparation</h2> | ||
</div> | ||
<div> | ||
<p> | ||
This function is used to play a predefined comment at a predetermined timing. | ||
</p> | ||
<p> | ||
The key is the slide number | ||
</p> | ||
<p> | ||
When you transition to the target slide number, a `comment` message is automatically posted after `seconds` seconds of each line | ||
</p> | ||
<p> | ||
To use this feature, the extension must also Start on the screen where the audience posts comments in the User Tools | ||
</p> | ||
</div> | ||
|
||
<hr /> | ||
<div>Configuration Structure(e.g.)</div> | ||
<pre> | ||
<code> | ||
{ | ||
"3": [ | ||
{"seconds": 0.5, "comment": "looks good"}, | ||
{"seconds": 1, "comment": "cooooooooooool!!!!"} | ||
], | ||
"4": [ | ||
{"seconds": 2, "comment": "wow"} | ||
] | ||
} | ||
</code> | ||
</pre> | ||
<hr /> | ||
|
||
<div id="optionsList"> | ||
</div> | ||
<textarea cols="100" rows="20" id="sakura"></textarea> | ||
<br /> | ||
<button class="save" id="save">Save</button> | ||
</body> | ||
<script src="options.js"></script> | ||
</html> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); |
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
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