Skip to content

Commit

Permalink
caption turn on notification and pageaction added
Browse files Browse the repository at this point in the history
  • Loading branch information
RutvijDv committed Mar 7, 2021
1 parent a1cc361 commit 2adf9ec
Show file tree
Hide file tree
Showing 7 changed files with 129 additions and 2 deletions.
61 changes: 61 additions & 0 deletions content.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
let ON_CALL = false;
let IS_SUBTITLE_ON = false;

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

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

const docObserver = new MutationObserver(() => {
if (document.body.querySelector("div[jscontroller='kAPMuc']")) {
ON_CALL = true;
// Remove observer
docObserver.disconnect();

chrome.runtime.sendMessage({
todo: "activate"
});

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

callStarts();
}
});

docObserver.observe(document.body, {
childList: true
});


function whenSubtitleOff() {
chrome.storage.sync.set({
subtitleWarning: true,
});
};


function callStarts() {
const subtitleDiv = document.querySelector("div[jscontroller='TEjq6e']");

// To notify the first time
IS_SUBTITLE_ON = subtitleDiv.style.display === "none" ? false : true;
if (IS_SUBTITLE_ON) whenSubtitleOn();
else whenSubtitleOff();

const subtitleObserver = new MutationObserver(() => {
IS_SUBTITLE_ON = subtitleDiv.style.display === "none" ? false : true;
if (IS_SUBTITLE_ON) whenSubtitleOn();
else whenSubtitleOff();
});

subtitleObserver.observe(subtitleDiv, {
attributes: true,
attributeOldValue: true,
attributeFilter: ["style"],
});
};
23 changes: 23 additions & 0 deletions event.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
chrome.runtime.onMessage.addListener(function (message, sender, sendResponse) {
if (message.todo == "activate") {
chrome.tabs.query({
active: true,
currentWindow: true
}, function (tabs) {
chrome.pageAction.show(tabs[0].id)
})
}
})

chrome.storage.sync.get(["subtitleWarning"], function (result) {
console.log("caps" + result.subtitleWarning);
if (result.subtitleWarning) {
var notifOption = {
type: "basic",
iconUrl: "icon.png",
title: "Caption Off!",
message: "Please turn on your CAPTIONS!!"
};
chrome.notifications.create("captionOff", notifOption);
}
})
Binary file added icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions jquery.min.js

Large diffs are not rendered by default.

15 changes: 13 additions & 2 deletions manifest.JSON
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,21 @@
"name":"Google-Meet-Notes",
"version":"1.0",
"description":"A google meet supported chrome extension that make notes using Captions",

"background": {
"scripts": ["event.js"],
"persistent": false
},
"page_action": {
"default_popup": "popup.html"
},

"content_scripts":[
{
"matches":["https://meet.google.com/*"],
"js":["./jquery.min.js","content.js"]
}
],
"permissions":[
"tabs","https://meet.google.com/*","storage","notifications"
]

}
25 changes: 25 additions & 0 deletions popup.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="">
</head>

<body style="height: fit-content;width: fit-content; ">

<div style="width: max-content;font-weight: bold;">
<p>Welcome To GMeet Notes</p>
</div>
<div id="meet-start"></div>


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

</html>
5 changes: 5 additions & 0 deletions popup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
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");
})

0 comments on commit 2adf9ec

Please sign in to comment.