Compare commits

...

6 Commits
v1.1 ... master

Author SHA1 Message Date
Ceda EI 05d4d14c3c Add background to permissions array. 2020-09-22 09:25:00 +05:30
Ceda EI 6bcef99546 Update build.sh 2020-09-20 12:42:42 +05:30
Ceda EI 33fcf0ab21 Move match actions to background.js.
Send notifications and play audio via message passing.
2020-09-20 12:35:43 +05:30
Ceda EI d2d435527e Add build.sh. Version bump. 2020-09-15 18:36:39 +05:30
Ceda EI e10e3f2016 Add notification sound upon match. 2020-09-15 18:29:44 +05:30
Ceda EI 4594a31115 Update README 2020-09-14 21:38:52 +05:30
6 changed files with 37 additions and 6 deletions

View File

@ -12,7 +12,7 @@ This will build the react app for popup.
+ `cd ..`
+ `FILENAME="$(basename "$PWD")-$(jq -r .version manifest.json).zip"`
+ `zip -r "web-ext-artifacts/$FILENAME" gmcr.js manifest.json popup/build/ icons/`
+ `zip -r "web-ext-artifacts/$FILENAME" LICENSE gmcr.js manifest.json popup/build/ icons/`
### Building source zip (for review process)

13
background.js Normal file
View File

@ -0,0 +1,13 @@
function handleMatch(match) {
new Notification("Match found", {body: match});
const audio = new Audio(browser.runtime.getURL("static/notif.mp3"));
audio.play();
}
function handleMessage(request) {
if (request.type == "match")
return handleMatch(request.match);
}
browser.runtime.onMessage.addListener(handleMessage);

11
build.sh Executable file
View File

@ -0,0 +1,11 @@
#!/usr/bin/env bash
cd popup
yarn install
yarn build
cd ..
[[ -d web-ext-artifacts ]] || mkdir web-ext-artifacts
FILENAME="$(basename "$PWD")-$(jq -r .version manifest.json).zip"
zip -r "web-ext-artifacts/$FILENAME" LICENSE gmcr.js manifest.json background.js popup/build/ icons/
zip -r "web-ext-artifacts/source-$FILENAME" $(git ls-files)

View File

@ -13,7 +13,6 @@ function surroundText(haystack, wordList, padding) {
surroundingText += "...";
surroundingText += "<br>";
console.log(start, end, surroundingText);
});
return surroundingText.trim();
}
@ -52,12 +51,14 @@ function captionUpdate() {
} else {
[ matched, surroundingText ] = simpleMatch(captions, storage.words);
}
console.log(matched, surroundingText);
/* The lastNotification prevents repetitive notifications because
* of constant updates.
*/
if (matched && surroundingText !== lastNotification) {
new Notification("Match found", {body: surroundingText});
browser.runtime.sendMessage({
type: "match",
match: surroundingText
});
lastNotification = surroundingText;
}
})

View File

@ -1,12 +1,13 @@
{
"manifest_version": 2,
"name": "Google Meet Caption Regex",
"version": "1.1",
"version": "1.4",
"description": "Send a notification when a caption in Google Meet matches a certain regex.",
"homepage_url": "https://gitlab.com/ceda_ei/google-meet-captions-regex",
"permissions": [
"background",
"notifications",
"storage"
],
@ -22,11 +23,16 @@
"default_popup": "popup/build/index.html"
},
"background": {
"scripts": ["background.js"]
},
"content_scripts": [
{
"matches": ["https://meet.google.com/*"],
"js": ["gmcr.js"]
}
]
],
"web_accessible_resources": ["static/*"]
}

BIN
static/notif.mp3 Normal file

Binary file not shown.