Skip to content

Commit

Permalink
saving text file of transcript done
Browse files Browse the repository at this point in the history
  • Loading branch information
RutvijDv committed Mar 8, 2021
1 parent be47c9c commit 70e27fb
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 24 deletions.
3 changes: 3 additions & 0 deletions FileSaver.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 34 additions & 22 deletions content.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
let ON_CALL = false;
let IS_SUBTITLE_ON = false;
let MEET_CODE;
let script = [];

chrome.storage.sync.set({
ON_CALL: false,
Expand All @@ -21,6 +23,7 @@ const docObserver = new MutationObserver(() => {

chrome.storage.sync.set({
ON_CALL: true,
script: script,
})

callStarts();
Expand All @@ -41,6 +44,8 @@ function whenSubtitleOff() {

function callStarts() {
const subtitleDiv = document.querySelector("div[jscontroller='TEjq6e']");
MEET_CODE = window.location.pathname;
MEET_CODE = MEET_CODE.substr(1, MEET_CODE.length - 1);

// To notify the first time
IS_SUBTITLE_ON = subtitleDiv.style.display === "none" ? false : true;
Expand All @@ -61,38 +66,45 @@ function callStarts() {
};


function whenSubtitleOn(){


function whenSubtitleOn() {
chrome.storage.sync.set({
subtitleWarning: false,
});


chrome.storage.sync.get(function (result) {
console.log(result);
})

// DOM element containing all subtitles
const subtitleDiv = document.querySelector("div[jscontroller='TEjq6e']");

const subtitleObserver = new MutationObserver((mutations) => {

mutations.forEach((mutation) => {
if(mutation.target.classList && mutation.target.classList.contains("iTTPOb")){
if(mutation.addedNodes.length){
var newNodes = mutation.addedNodes;
var speaker = newNodes["0"]?.parentNode?.parentNode?.parentNode?.querySelector(".zs7s8d.jxFHg")?.textContent;
setTimeout(function () {
if(newNodes.length){
console.log(speaker + " : " + newNodes["0"].innerText);
}
}, 10000);

mutations.forEach((mutation) => {
if (mutation.target.classList && mutation.target.classList.contains("iTTPOb")) {
if (mutation.addedNodes.length) {
var newNodes = mutation.addedNodes;
var speaker = newNodes["0"] ? .parentNode ? .parentNode ? .parentNode ? .querySelector(".zs7s8d.jxFHg") ? .textContent;
setTimeout(function () {
if (newNodes.length) {
console.log(speaker + " : " + newNodes["0"].innerText);
script.push(speaker + " : " + newNodes["0"].innerText + "\r\n");

chrome.storage.sync.set({
script: script,
})
}
}, 10000);
}
}
}
});
});
});

// Start observing subtitle div
subtitleObserver.observe(subtitleDiv, {
childList: true,
subtree: true,
attributes: false,
characterData: false,
childList: true,
subtree: true,
attributes: false,
characterData: false,
});
};
};
2 changes: 1 addition & 1 deletion manifest.JSON
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"content_scripts":[
{
"matches":["https://meet.google.com/*"],
"js":["./jquery.min.js","content.js"]
"js":["jquery.min.js","FileSaver.min.js","content.js"]
}
],
"permissions":[
Expand Down
3 changes: 2 additions & 1 deletion popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
<p>Welcome To GMeet Notes</p>
</div>
<div id="meet-start"></div>

<button id="download">download</button>

<script src="jquery.min.js"></script>
<script src="FileSaver.min.js"></script>
<script src="popup.js"></script>
</body>

Expand Down
11 changes: 11 additions & 0 deletions popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,15 @@ chrome.storage.sync.get(["ON_CALL"], function (result) {
console.log(result);
if (result.ON_CALL) $("#meet-start").html("Meet - Started");
else $("#meet-start").html("Meet - Not - Started");
})

$("#download").on('click', function () {
chrome.storage.sync.get(["script"], function (output) {

var blob = new Blob(output.script, {
type: "text/plain;charset=utf-8"
});

saveAs(blob, "script.txt");
})
})

0 comments on commit 70e27fb

Please sign in to comment.