├── perms.js ├── gsum_logo.ico ├── perms.html ├── home.css ├── global.js ├── package.json ├── README.md ├── style.css.map ├── manifest.json ├── login.html ├── register.html ├── screenshot.html ├── screenshot.js ├── style.css ├── style.scss ├── index.html ├── auth.js └── app.js /perms.js: -------------------------------------------------------------------------------- 1 | var recognition = new webkitSpeechRecognition(); 2 | recognition.start(); -------------------------------------------------------------------------------- /gsum_logo.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gisty-org/chrome-extension/HEAD/gsum_logo.ico -------------------------------------------------------------------------------- /perms.html: -------------------------------------------------------------------------------- 1 | 2 |

ASKING FOR PERMISSIONS

3 | 4 | -------------------------------------------------------------------------------- /home.css: -------------------------------------------------------------------------------- 1 | /* body{ 2 | background-color: #222222; 3 | color:rgb(93,205,136); 4 | } 5 | input{ 6 | background-color: inherit; 7 | } 8 | input::placeholder{ 9 | color:rgb(93,205,136); 10 | } */ 11 | -------------------------------------------------------------------------------- /global.js: -------------------------------------------------------------------------------- 1 | const CHROME_EXTENSION_ID = "aemdihmkgckmpjgfofgkgdpeekececla"; 2 | const BASE_URL = "https://gisty-server.herokuapp.com"; 3 | const BASE_URL_VS = "http://localhost:5000"; 4 | const TEMP_EMAIL = "yashtailor2000@gmail.com"; 5 | // const BASE_URL_VS = "https://gisty-summarizer-server.herokuapp.com" 6 | 7 | 8 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "extension", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "app.js", 6 | "dependencies": { 7 | "axios": "^0.21.1", 8 | "dotenv": "^8.2.0" 9 | }, 10 | "devDependencies": {}, 11 | "scripts": { 12 | "test": "echo \"Error: no test specified\" && exit 1", 13 | "dev": "parcel index.html", 14 | "build": "parcel build index.html" 15 | }, 16 | "keywords": [], 17 | "author": "", 18 | "license": "ISC" 19 | } 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## A chrome extension to capture captions of google meet and convert voice to text using webkitspeechrecognition api for meets other than google meet. 2 | 3 | #### Steps to use chrome extension: 4 | 1) Clone the repo 5 | 2) Open google chrome > (3 dots at top right)customize and control google chrome > more tools > Extensions 6 | 3) Click on load unpacked and browse to the folder where the project lies 7 | 4) Copy the ID generated and replace it with CHROME_EXTENSION_ID in global.js file. 8 | 5) Click on the refresh button of the extension tile. 9 | 10 | *Enjoi using the extension :yum:* 11 | -------------------------------------------------------------------------------- /style.css.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sourceRoot":"","sources":["style.scss"],"names":[],"mappings":"AACQ;AAOR;AAAA;AAAA;EAGE;EACA;EACA;;;AAGF;EACI;EACA;;;AAGJ;EACI,OAjBI;;;AAoBR;EACE;EACA;EACA;EACA,aA1BI;EA2BJ;EACA;;;AAGF;EACE;EACA;EACA;;;AAGF;EACE,OApCM;EAqCN;EACA;EACA;EACA;;AACA;EACE;;AAEF;EACE;;;AAIJ;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AACA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,kBAzEI;EA0EJ;;AAGA;EACE;EACA;EACA;EACA;EACA;;AAIF;EACE;EACA;EACA;EACA;EACA;;;AAKN;EACC;EACG;;;AAEJ;EACC;EACA;EACA;EACA;EACA;EACA;;;AAED;EACE;EACA;EACA;EACA;EACA;EACA;EACA;;;AAEF;EACC;EACA;EACA;;;AAGD;AAAA;EAEC;EACA","file":"style.css"} -------------------------------------------------------------------------------- /manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Gisty", 3 | "version": "1.0", 4 | "manifest_version": 2, 5 | "content_scripts": [ 6 | { 7 | "matches": [ 8 | "" 9 | ], 10 | "js": [ 11 | "app.js", 12 | "perms.js", 13 | "auth.js" 14 | ] 15 | } 16 | ], 17 | "browser_action": { 18 | "default_popup": "login.html", 19 | "default_title": "Gsum" 20 | }, 21 | "permissions": [ 22 | "activeTab", 23 | "tabs", 24 | "pageCapture", 25 | "storage", 26 | "ttsEngine", 27 | "contextMenus", 28 | "notifications" 29 | ], 30 | "background":{ 31 | "scripts":["app.js"], 32 | "persistent":true 33 | } 34 | } -------------------------------------------------------------------------------- /login.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | login 4 | 5 | 6 | 7 | 8 |

Login

9 |
10 | 11 |
12 |
13 | 14 |
15 |
16 | 17 | Don't have an account? Register here 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /register.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | login 4 | 5 | 6 | 7 | 8 | 9 |

Register

10 | 13 |
14 | 15 |
16 |
17 | 18 |
19 |
20 | 21 |
22 |
23 | 24 |
25 |
26 | 27 | Already have an account? Login here 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /screenshot.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /screenshot.js: -------------------------------------------------------------------------------- 1 | var CLOUDINARY_URL = "https://api.cloudinary.com/v1_1/codemafia/image/upload"; 2 | var CLOUDINARY_UPLOAD_PRESET = "ksx2b0v2"; 3 | 4 | const canIRun = navigator.mediaDevices.getDisplayMedia; 5 | 6 | function acknowledgeSSSuccess() { 7 | var ss = document.getElementById("ss"); 8 | ss.style.display = "none"; 9 | ss_in.style.display = "inline-block"; 10 | setTimeout(() => { 11 | ss.style.display = "inline-block"; 12 | ss_in.style.display = "none"; 13 | }, 3000); 14 | } 15 | 16 | const takeScreenShot = async (e) => { 17 | chrome.tabs.captureVisibleTab(async function (imageUri) { 18 | console.log(imageUri); 19 | const res = await fetch(imageUri); 20 | const buff = await res.arrayBuffer(); 21 | // clone so we can rename, and put into array for easy proccessing 22 | const file = [ 23 | new File([buff], `photo_${new Date()}.jpg`, { 24 | type: "image/jpeg", 25 | }), 26 | ]; 27 | console.log(file[0]); 28 | var formData = new FormData(); 29 | formData.append("file", file[0]); 30 | formData.append("upload_preset", CLOUDINARY_UPLOAD_PRESET); 31 | formData.append("tags", "browser_upload"); 32 | // alert(formData); 33 | for (var pair of formData.entries()) { 34 | console.log(pair[0] + ", " + pair[1]); 35 | } 36 | console.log(formData); 37 | const req = new XMLHttpRequest(); 38 | req.open("POST", CLOUDINARY_URL); 39 | req.setRequestHeader("X-Requested-With", "XMLHttpRequest"); 40 | req.send(formData); 41 | 42 | req.onreadystatechange = function () { 43 | // Call a function when the state changes. 44 | if (this.readyState === XMLHttpRequest.DONE && this.status === 200) { 45 | console.log("Got response 200!"); 46 | var response = JSON.parse(req.responseText); 47 | var url = response.secure_url; 48 | if (JSON.parse(localStorage.getItem("images")) == null) { 49 | var img = [url]; 50 | localStorage.setItem("images", JSON.stringify(img)); 51 | console.log(JSON.parse(localStorage.getItem("images"))); 52 | } else { 53 | var imgs = JSON.parse(localStorage.getItem("images")); 54 | console.log(imgs); 55 | imgs.push(url); 56 | localStorage.setItem("images", JSON.stringify(imgs)); 57 | console.log(JSON.parse(localStorage.getItem("images"))); 58 | } 59 | console.log(localStorage.getItem("images")); 60 | } else { 61 | console.log(req.response); 62 | } 63 | }; 64 | console.log(req.response); 65 | console.log(req.response.secure_url); 66 | acknowledgeSSSuccess(); 67 | return file; 68 | }); 69 | }; 70 | 71 | const button = (document.getElementById("ss").onclick = () => 72 | canIRun ? takeScreenShot() : {}); 73 | -------------------------------------------------------------------------------- /style.css: -------------------------------------------------------------------------------- 1 | @import 'https://fonts.googleapis.com/css?family=Source+Sans+Pro:700'; 2 | *, 3 | *::before, 4 | *::after { 5 | -webkit-box-sizing: border-box; 6 | -moz-box-sizing: border-box; 7 | box-sizing: border-box; 8 | } 9 | 10 | html, body { 11 | height: 100%; 12 | width: 200px; 13 | } 14 | 15 | h3 { 16 | color: #667eea; 17 | } 18 | 19 | body { 20 | padding: 0px; 21 | margin: 0; 22 | text-align: center; 23 | font-family: "cursive", sans-serif; 24 | background: #24252A; 25 | -webkit-font-smoothing: antialiased; 26 | } 27 | 28 | .flex { 29 | display: flex; 30 | align-items: center; 31 | justify-content: center; 32 | } 33 | 34 | .btn { 35 | color: #667eea; 36 | background-color: #24252A; 37 | text-decoration: none; 38 | -webkit-transition: 0.3s all ease; 39 | transition: 0.3s ease all; 40 | } 41 | .btn:hover { 42 | color: #FFF; 43 | } 44 | .btn:focus { 45 | color: #FFF; 46 | } 47 | 48 | .btn { 49 | font-size: 10px; 50 | width: 50%; 51 | letter-spacing: 2px; 52 | text-transform: uppercase; 53 | display: inline-block; 54 | text-align: center; 55 | font-weight: bold; 56 | padding: 5px 0px; 57 | border: 3px solid #667eea; 58 | border-radius: 2px; 59 | position: relative; 60 | box-shadow: 0 2px 5px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.1); 61 | z-index: 2; 62 | } 63 | .btn:before { 64 | -webkit-transition: 0.5s all ease; 65 | transition: 0.5s all ease; 66 | position: absolute; 67 | top: 0; 68 | left: 50%; 69 | right: 50%; 70 | bottom: 0; 71 | opacity: 0; 72 | content: ""; 73 | background-color: #667eea; 74 | z-index: -1; 75 | } 76 | .btn:hover:before { 77 | -webkit-transition: 0.5s all ease; 78 | transition: 0.5s all ease; 79 | left: 0; 80 | right: 0; 81 | opacity: 1; 82 | } 83 | .btn:focus:before { 84 | -webkit-transition: 0.5s all ease; 85 | transition: 0.5s all ease; 86 | left: 0; 87 | right: 0; 88 | opacity: 1; 89 | } 90 | 91 | .input-container { 92 | position: relative; 93 | margin-bottom: 15px; 94 | } 95 | 96 | .input-container label { 97 | position: absolute; 98 | top: 0px; 99 | left: 0px; 100 | font-size: 15px; 101 | color: #fff; 102 | transition: all 0.5s ease-in-out; 103 | } 104 | 105 | .input-container input { 106 | border: 0; 107 | border-bottom: 1px solid #555; 108 | background: transparent; 109 | width: 100%; 110 | padding: 8px 0 5px 0; 111 | font-size: 15px; 112 | color: #fff; 113 | } 114 | 115 | .input-container input:focus { 116 | border: none; 117 | outline: none; 118 | border-bottom: 1px solid #667eea; 119 | } 120 | 121 | .input-container input:focus ~ label, 122 | .input-container input:valid ~ label { 123 | top: -10px; 124 | font-size: 10px; 125 | } 126 | 127 | /*# sourceMappingURL=style.css.map */ 128 | -------------------------------------------------------------------------------- /style.scss: -------------------------------------------------------------------------------- 1 | 2 | @import 'https://fonts.googleapis.com/css?family=Source+Sans+Pro:700'; 3 | 4 | $font:'cursive', sans-serif; 5 | $primary:#FF0072; 6 | $second:rgb(93,205,136); 7 | $third:#4426a8; 8 | 9 | *, 10 | *::before, 11 | *::after { 12 | -webkit-box-sizing: border-box; 13 | -moz-box-sizing: border-box; 14 | box-sizing: border-box; 15 | } 16 | 17 | html, body{ 18 | height:100%; 19 | width: 200px; 20 | } 21 | 22 | h3{ 23 | color:$second 24 | } 25 | 26 | body { 27 | padding:0px; 28 | margin:0; 29 | text-align: center; 30 | font-family:$font; 31 | background:#24252A; 32 | -webkit-font-smoothing: antialiased; 33 | } 34 | 35 | .flex { 36 | display:flex; 37 | align-items:center; 38 | justify-content:center; 39 | } 40 | 41 | .btn { 42 | color:$second; 43 | background-color: #24252A; 44 | text-decoration:none; 45 | -webkit-transition:0.3s all ease; 46 | transition:0.3s ease all; 47 | &:hover { 48 | color:#FFF; 49 | } 50 | &:focus { 51 | color:#FFF; 52 | } 53 | } 54 | 55 | .btn { 56 | font-size:10px; 57 | width:50%; 58 | letter-spacing:2px; 59 | text-transform:uppercase; 60 | display:inline-block; 61 | text-align:center; 62 | font-weight:bold; 63 | padding:5px 0px; 64 | border:3px solid $second; 65 | border-radius:2px; 66 | position:relative; 67 | box-shadow: 0 2px 5px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.1); 68 | z-index:2; 69 | &:before { 70 | -webkit-transition:0.5s all ease; 71 | transition:0.5s all ease; 72 | position:absolute; 73 | top:0; 74 | left:50%; 75 | right:50%; 76 | bottom:0; 77 | opacity:0; 78 | content:''; 79 | background-color:$second; 80 | z-index:-1; 81 | } 82 | &:hover { 83 | &:before { 84 | -webkit-transition:0.5s all ease; 85 | transition:0.5s all ease; 86 | left:0; 87 | right:0; 88 | opacity:1; 89 | } 90 | } 91 | &:focus { 92 | &:before { 93 | -webkit-transition:0.5s all ease; 94 | transition:0.5s all ease; 95 | left:0; 96 | right:0; 97 | opacity:1; 98 | } 99 | } 100 | } 101 | 102 | .input-container{ 103 | position:relative; 104 | margin-bottom:15px; 105 | } 106 | .input-container label{ 107 | position:absolute; 108 | top:0px; 109 | left:0px; 110 | font-size:15px; 111 | color:#fff; 112 | transition: all 0.5s ease-in-out; 113 | } 114 | .input-container input{ 115 | border:0; 116 | border-bottom:1px solid #555; 117 | background:transparent; 118 | width:100%; 119 | padding:8px 0 5px 0; 120 | font-size:15px; 121 | color:#fff; 122 | } 123 | .input-container input:focus{ 124 | border:none; 125 | outline:none; 126 | border-bottom:1px solid rgb(93,205,136); 127 | } 128 | 129 | .input-container input:focus ~ label, 130 | .input-container input:valid ~ label{ 131 | top:-10px; 132 | font-size:10px; 133 | 134 | } 135 | 136 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Extension 4 | 5 | 11 | 16 | 21 | 22 | 23 | 27 | 28 | 32 | 33 | 34 |
37 | Gisty 40 | logout 46 |
47 | 48 | 55 |
56 |
57 | 63 | 64 |
65 |
66 | 72 | 73 |
74 |
75 | 83 | 84 |
85 | 86 | 87 | 90 | 91 | 94 | 97 |
98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 111 | -------------------------------------------------------------------------------- /auth.js: -------------------------------------------------------------------------------- 1 | var register_btn = document.getElementById('register_btn'); 2 | var login_btn = document.getElementById('login_btn'); 3 | var error_text = document.getElementById('error_text'); 4 | var logout_btn = document.getElementById('logout_btn'); 5 | 6 | if(localStorage.getItem('user') != null){ 7 | chrome.browserAction.setPopup({popup: 'index.html'}); 8 | } 9 | 10 | if(register_btn){ 11 | register_btn.addEventListener('click',function(e){ 12 | var password = document.getElementById('password').value; 13 | var fullname = document.getElementById('fullname').value; 14 | var contact = document.getElementById('contact').value; 15 | var email = document.getElementById('email').value; 16 | e.preventDefault(); 17 | 18 | const req = new XMLHttpRequest(); 19 | const baseUrl = BASE_URL+"/api/register"; 20 | 21 | const urlParams = { 22 | "fullname":fullname, 23 | "email":email, 24 | "contact":contact, 25 | "password":password, 26 | }; 27 | 28 | req.open("POST", baseUrl); 29 | req.setRequestHeader("Content-Type", "application/json"); 30 | req.setRequestHeader( 'Access-Control-Allow-Origin', '*'); 31 | req.send(JSON.stringify(urlParams)); 32 | // req.onload = function(){ 33 | // if(req.status == 200){ 34 | // var res = req.response; 35 | // var JSONres = JSON.parse(res); 36 | // var user = JSONres.user; 37 | // localStorage.setItem('user',JSON.stringify(user)); 38 | // console.log(localStorage.getItem('user')); 39 | // location.replace('index.html'); 40 | // }else{ 41 | // console.log(req,req.statusText); 42 | // error_text.value = req.statusText; 43 | // error_text.style.display = 'inline-block'; 44 | // } 45 | // } 46 | // req.onerror = function(){ 47 | // console.log('This is the error'); 48 | // } 49 | req.onreadystatechange = function() { 50 | console.log("readystate: " + request.readyState); 51 | if(request.readyState == 4) { 52 | console.log("status: " + request.status); 53 | if (request.status == 401) { 54 | //navigator.notification.alert("Your login/password is incorrect",null,"Authentication Error","OK"); 55 | console.log('came insideee'); 56 | return; 57 | } 58 | } 59 | } 60 | 61 | req.onreadystatechange = function() { 62 | if(req.readyState == 4) { 63 | if (req.status != 200) { 64 | var response_error = JSON.parse(req.response); 65 | error_text.style.display = 'inline-block'; 66 | error_text.innerHTML = response_error.error; 67 | }else{ 68 | var res = req.response; 69 | var JSONres = JSON.parse(res); 70 | var user = JSONres.user; 71 | localStorage.setItem('user',JSON.stringify(user)); 72 | console.log(localStorage.getItem('user')); 73 | location.replace('index.html'); 74 | } 75 | } 76 | } 77 | }) 78 | } 79 | 80 | if(login_btn){ 81 | login_btn.addEventListener('click',function(e){ 82 | var email = document.getElementById('email').value; 83 | var password = document.getElementById('password').value; 84 | e.preventDefault(); 85 | const req = new XMLHttpRequest(); 86 | const baseUrl = BASE_URL+"/api/login"; 87 | 88 | const urlParams = { 89 | "email":email, 90 | "password":password, 91 | }; 92 | console.log('came here') 93 | req.open("POST", baseUrl); 94 | req.setRequestHeader("Content-Type", "application/json"); 95 | req.setRequestHeader( 'Access-Control-Allow-Origin', '*'); 96 | req.send(JSON.stringify(urlParams)); 97 | 98 | req.onreadystatechange = function() { 99 | if(req.readyState == 4) { 100 | if (req.status != 200) { 101 | var response_error = JSON.parse(req.response); 102 | error_text.style.display = 'inline-block'; 103 | error_text.innerHTML = response_error.error; 104 | }else{ 105 | var res = req.response; 106 | var JSONres = JSON.parse(res); 107 | var user = JSONres.user; 108 | localStorage.setItem('user',JSON.stringify(user)); 109 | console.log(localStorage.getItem('user')); 110 | location.replace('index.html'); 111 | } 112 | } 113 | } 114 | }) 115 | } 116 | 117 | if(logout_btn){ 118 | logout_btn.addEventListener('click',function(){ 119 | localStorage.setItem("user",null); 120 | location.replace('login.html'); 121 | }) 122 | } -------------------------------------------------------------------------------- /app.js: -------------------------------------------------------------------------------- 1 | var submit_button = document.getElementById("submit"); 2 | var start_button = document.getElementById("start"); 3 | var stop_button = document.getElementById("stop"); 4 | var resume_button = document.getElementById("resume"); 5 | var ss_button = document.getElementById("ss"); 6 | var clear_button = document.getElementById("clear"); 7 | var is_google_meet = false; 8 | var spanClassName = "CNusmb"; 9 | var div = document.getElementById("span_text"); 10 | var idx = 1; 11 | var catch_meet = false; 12 | var google_meet_transcript_data = ""; 13 | var take_snapshot = false; 14 | var turned_on_captions_flag = false; 15 | 16 | function get_data(turned_on_captions_flag) { 17 | var turnOnMeetCaptionsClass = "I98jWb"; 18 | console.log("TOCF:",turned_on_captions_flag); 19 | if(turned_on_captions_flag == true){ 20 | var turnOnMeetCaptionsDiv = document.getElementsByClassName(turnOnMeetCaptionsClass); 21 | if(turnOnMeetCaptionsDiv.length == 0){ 22 | // alert("Please Turn On your Captions for Recording"); 23 | }else{ 24 | turnOnMeetCaptionsDiv[0].click(); 25 | } 26 | } 27 | //console.log('came here'); 28 | var idx = 1; 29 | var spans = document.getElementsByClassName("CNusmb"); 30 | // console.log(spans); 31 | var take_snapshot = false; 32 | var global_text = ""; 33 | for (let i = 0; i < spans.length; i++) { 34 | console.log(spans[i].innerText, spans[i].classList.contains("from-cs")); 35 | if (!spans[i].classList.contains("from-cs")) { 36 | spans[i].classList.add("from-cs"); 37 | var text = spans[i].innerText.toLowerCase(); 38 | var res = text.split(" "); 39 | //console.log(res); 40 | for (let i = 0; i < res.length; i++) { 41 | if (res[i] == "take") { 42 | if ( 43 | i != res.length - 1 && 44 | (res[i + 1] == "snapshot" || res[i + 1] == "snapshot.") 45 | ) { 46 | console.log("detected take snapshot"); 47 | take_snapshot = true; 48 | } 49 | } 50 | } 51 | global_text += text; 52 | global_text += " "; 53 | // console.log(text); 54 | // div.textContent += text; 55 | } 56 | } 57 | return { text: global_text, flag: take_snapshot }; 58 | } 59 | 60 | function start_fetching_meet() { 61 | console.log("started"); 62 | // while(true){ 63 | if (catch_meet) { 64 | //console.log('inside'); 65 | setTimeout(() => { 66 | chrome.tabs.executeScript( 67 | null, 68 | { code: "(" + get_data + ")("+turned_on_captions_flag+");" }, 69 | (results) => { 70 | // console.log('FUN RES'); 71 | // console.log(results); 72 | // div.innerText += " "; 73 | // div.innerText += results; 74 | 75 | turned_on_captions_flag = false; 76 | google_meet_transcript_data += " "; 77 | google_meet_transcript_data += results[0].text; 78 | localStorage.setItem("meet-data", google_meet_transcript_data); 79 | console.log(results[0].flag, results, "value of take snapshot bool"); 80 | if (results[0].flag) { 81 | console.log("take snapshot!! :)"); 82 | takeScreenShot(); 83 | acknowledgeSSSuccess(); 84 | } 85 | start_fetching_meet(); 86 | } 87 | ); 88 | }, 5000); 89 | } else return; 90 | // } 91 | } 92 | 93 | function get_host_name() { 94 | return window.location.host; 95 | } 96 | 97 | if(localStorage.getItem('meet-data-store')=="true"){ 98 | document.getElementById("subject_name").value = localStorage.getItem('meet-name'); 99 | document.getElementById("lecture_name").value = localStorage.getItem('meet-topic'); 100 | document.getElementById("num_lines").value = localStorage.getItem('meet-lines'); 101 | start_helper(); 102 | } 103 | 104 | async function start_helper(){ 105 | if(localStorage.getItem('meet-data-store') == null || localStorage.getItem("meet-data-store")==false){ 106 | localStorage.setItem("images", JSON.stringify([])); 107 | localStorage.setItem("meet-data", " "); 108 | } 109 | //keep it waiting 110 | localStorage.setItem('meet-data-store',true); 111 | const subject_name = document.getElementById("subject_name").value; 112 | const lecture_name = document.getElementById("lecture_name").value; 113 | const num_lines = document.getElementById("num_lines").value; 114 | localStorage.setItem('meet-name',subject_name); 115 | localStorage.setItem('meet-topic',lecture_name); 116 | localStorage.setItem('meet-lines',num_lines); 117 | await chrome.tabs.executeScript( 118 | null, 119 | { code: "(" + get_host_name + ")();" }, 120 | (results) => { 121 | console.log(results); 122 | if (results[0] == "meet.google.com") { 123 | is_google_meet = true; 124 | console.log("It is a G Meet"); 125 | } 126 | if (is_google_meet) { 127 | catch_meet = true; 128 | turned_on_captions_flag = true; 129 | console.log("starting recording..."); 130 | submit_button.style.display = "inline-block"; 131 | stop_button.style.display = "inline-block"; 132 | start_button.style.display = "none"; 133 | start_fetching_meet(); 134 | } else toggleSpeechRecognition(); 135 | } 136 | ); 137 | } 138 | start_button.addEventListener("click", async function () { 139 | start_helper(); 140 | }); 141 | 142 | submit_button.addEventListener("click", function (e) { 143 | localStorage.setItem('meet-data-store',false); 144 | e.preventDefault(); 145 | if (!is_google_meet) toggleSpeechRecognition(); 146 | else { 147 | recognizing = false; 148 | submit_button.style.display = "none"; 149 | stop_button.style.display = "none"; 150 | resume_button.style.display = "none"; 151 | start_button.style.display = "inline-block"; 152 | } 153 | const req = new XMLHttpRequest(); 154 | const baseUrl = BASE_URL_VS + "/text/1"; 155 | const subject_name = document.getElementById("subject_name").value; 156 | const lecture_name = document.getElementById("lecture_name").value; 157 | const num_lines = document.getElementById("num_lines").value; 158 | if (num_lines == null) num_lines = -1; 159 | // const transcript = document.getElementById('transcript').value; 160 | // const transcript_data = localStorage.getItem('current_session'); 161 | if (is_google_meet) { 162 | catch_meet = false; 163 | transcript_data = localStorage.getItem("google-meet-data"); 164 | } 165 | const urlParams = { 166 | subject_name: subject_name, 167 | lecture_name: lecture_name, 168 | transcript: localStorage.getItem("meet-data"), 169 | user_id: JSON.parse(localStorage.getItem("user")).userId, 170 | email: 171 | (JSON.parse(localStorage.getItem("user")) && 172 | JSON.parse(localStorage.getItem("user")).email) || 173 | TEMP_EMAIL, 174 | images: JSON.parse(localStorage.getItem("images")), 175 | is_gmeet: is_google_meet, 176 | num_lines: num_lines, 177 | }; 178 | console.log(urlParams); 179 | req.open("POST", baseUrl); 180 | req.setRequestHeader("Content-Type", "application/json"); 181 | req.send(JSON.stringify(urlParams)); 182 | 183 | req.onreadystatechange = function () { 184 | // Call a function when the state changes. 185 | if (this.readyState === XMLHttpRequest.DONE && this.status === 200) { 186 | console.log("Got response 200!"); 187 | transcript_data = []; 188 | localStorage.setItem("images", null); 189 | } 190 | }; 191 | 192 | is_google_meet = false; 193 | }); 194 | 195 | stop_button.addEventListener("click", function (e) { 196 | e.preventDefault(); 197 | if (!is_google_meet) toggleSpeechRecognition(); 198 | else { 199 | recognizing = false; 200 | catch_meet = false; 201 | stop_button.style.display = "none"; 202 | resume_button.style.display = "inline-block"; 203 | } 204 | }); 205 | 206 | resume_button.addEventListener("click", function (e) { 207 | e.preventDefault(); 208 | if (!is_google_meet) toggleSpeechRecognition(); 209 | else { 210 | recognizing = true; 211 | catch_meet = true; 212 | stop_button.style.display = "inline-block"; 213 | resume_button.style.display = "none"; 214 | console.log("resume"); 215 | } 216 | start_fetching_meet(); 217 | }); 218 | 219 | clear_button.addEventListener('click',function(){ 220 | localStorage.setItem('meet-data-store',false); 221 | }) 222 | 223 | var recognizing = false; 224 | var recognition = new webkitSpeechRecognition(); 225 | var transcript_data = []; 226 | var start_time; 227 | var end_time; 228 | recognition.continuous = true; 229 | recognition.interimResults = true; 230 | 231 | recognition.onstart = function () { 232 | recognizing = true; 233 | recordSession(); 234 | }; 235 | 236 | recognition.onerror = function (event) { 237 | console.log( 238 | "Recognition error: ", 239 | event.message ? event.message : event.error 240 | ); 241 | if (event.error == "not-allowed") { 242 | window.open("chrome-extension://" + CHROME_EXTENSION_ID + "/perms.html"); 243 | } 244 | if ( 245 | event.error == "no-speech" || 246 | event.error == "audio-capture" || 247 | event.error == "network" || 248 | event.error == "bad-grammar" 249 | ) { 250 | refresh(); 251 | } 252 | }; 253 | 254 | recognition.onend = function () { 255 | recognizing = false; 256 | }; 257 | 258 | recognition.onresult = function (event) { 259 | for (var i = event.resultIndex; i < event.results.length; ++i) { 260 | if (event.results[i][0].confidence > 0.1) { 261 | if (event.results[i].isFinal) { 262 | console.log(event.results); 263 | var text = event.results[i][0].transcript; 264 | addToTranscript("current_session", text); 265 | var res = text.split(" "); 266 | for (let i = 0; i < res.length; i++) { 267 | if (res[i] == "take") { 268 | if (i != res.length - 1 && (res[i + 1] == "snapshot" || res[i+1]=="snapshot.")) { 269 | takeScreenShot(); 270 | acknowledgeSSSuccess(); 271 | } 272 | } 273 | } 274 | } 275 | } 276 | } 277 | }; 278 | 279 | function toggleSpeechRecognition(event) { 280 | if (recognizing) { 281 | recognition.stop(); 282 | submit_button.style.display = "none"; 283 | stop_button.style.display = "inline-block"; 284 | start_button.style.display = "inline-block"; 285 | return; 286 | } else { 287 | submit_button.style.display = "inline-block"; 288 | start_button.style.display = "none"; 289 | recognition.start(); 290 | } 291 | } 292 | 293 | function recordSession() { 294 | createSession(); 295 | 296 | beginTime = new Date(); 297 | 298 | window.location.hash = currentSession.name; 299 | } 300 | 301 | function createSession() { 302 | var id, name, startTime; 303 | name = "new_session"; 304 | startTime = new Date(); 305 | currentSession = { id: id, name: name, startTime: startTime }; 306 | // saveToLocalStorage('current_session', currentSession); 307 | } 308 | 309 | function addToTranscript(sessionName, text) { 310 | if (text) { 311 | var endTime = new Date(); 312 | transcript_data.push({ 313 | startTime: beginTime, 314 | endTime: endTime, 315 | text: text, 316 | }); 317 | // Reset the beginTime 318 | beginTime = endTime; 319 | console.log(transcript_data); 320 | // saveToLocalStorage(sessionName, JSON.stringify(transcript)); 321 | } 322 | } 323 | 324 | function saveToLocalStorage(key, data) { 325 | if (data && localStorage) { 326 | if (typeof data === "object") { 327 | localStorage.setItem(key, JSON.stringify(data)); 328 | } else { 329 | localStorage.setItem(key, data); 330 | } 331 | } 332 | } 333 | 334 | function refresh(event) { 335 | recognizing = false; 336 | recognition.abort(); 337 | try { 338 | recognition.start(); 339 | } catch (e) {} 340 | } 341 | --------------------------------------------------------------------------------