Compare commits
4 Commits
Author | SHA1 | Date |
---|---|---|
Ceda EI | 05d4d14c3c | |
Ceda EI | 6bcef99546 | |
Ceda EI | 33fcf0ab21 | |
Ceda EI | d2d435527e |
|
@ -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);
|
|
@ -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)
|
9
gmcr.js
9
gmcr.js
|
@ -13,7 +13,6 @@ function surroundText(haystack, wordList, padding) {
|
|||
surroundingText += "...";
|
||||
|
||||
surroundingText += "<br>";
|
||||
console.log(start, end, surroundingText);
|
||||
});
|
||||
return surroundingText.trim();
|
||||
}
|
||||
|
@ -52,15 +51,15 @@ 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;
|
||||
const audio = new Audio(browser.runtime.getURL("static/notif.mp3"));
|
||||
audio.play();
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -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/*"]
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue