commit 18f1f240bc94b97f3635ef4c19d0039a8fd2be9b Author: Jeremy Dixon Date: Sun Jan 17 21:25:11 2021 -0600 first commit diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..c328838 Binary files /dev/null and b/.DS_Store differ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..85eb10a --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021 Noxid86 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..e081a45 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# AskBcsAssistant +A small chrome plugin for managing a work slack diff --git a/assets/.DS_Store b/assets/.DS_Store new file mode 100644 index 0000000..46f7ed5 Binary files /dev/null and b/assets/.DS_Store differ diff --git a/assets/icons/icon128.png b/assets/icons/icon128.png new file mode 100644 index 0000000..e5d9c24 Binary files /dev/null and b/assets/icons/icon128.png differ diff --git a/assets/icons/icon16.png b/assets/icons/icon16.png new file mode 100644 index 0000000..7a8c47c Binary files /dev/null and b/assets/icons/icon16.png differ diff --git a/assets/icons/icon48.png b/assets/icons/icon48.png new file mode 100644 index 0000000..e4b9eac Binary files /dev/null and b/assets/icons/icon48.png differ diff --git a/assets/images/gear.png b/assets/images/gear.png new file mode 100644 index 0000000..02e1d56 Binary files /dev/null and b/assets/images/gear.png differ diff --git a/assets/sounds/alert0.mp3 b/assets/sounds/alert0.mp3 new file mode 100644 index 0000000..1ba7141 Binary files /dev/null and b/assets/sounds/alert0.mp3 differ diff --git a/assets/sounds/alert1.mp3 b/assets/sounds/alert1.mp3 new file mode 100644 index 0000000..6e13b84 Binary files /dev/null and b/assets/sounds/alert1.mp3 differ diff --git a/assets/sounds/alert2.mp3 b/assets/sounds/alert2.mp3 new file mode 100644 index 0000000..d398c6d Binary files /dev/null and b/assets/sounds/alert2.mp3 differ diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..895d1ab --- /dev/null +++ b/manifest.json @@ -0,0 +1,26 @@ +{ + "name": "AskBCS Assistant", + "version": "1.0", + "description": "", + "icons": { + "16": "./assets/icons/icon16.png", + "48": "./assets/icons/icon48.png", + "128": "./assets/icons/icon128.png" }, + "background": { + "scripts": ["script_background.js"] + }, + "web_accessible_resources": [ + "./assets/alert0.mp3", + "./assets/alert1.mp3", + "./assets/alert2.mp3", + "toolbar.html" + ], + "content_scripts": [ + { + "matches": ["https://app.slack.com/client/TLXH0JYKB/*"], + "js": ["script_foreground.js"], + "css": ["styles.css"] + } + ], + "manifest_version": 2 +} \ No newline at end of file diff --git a/script_background.js b/script_background.js new file mode 100644 index 0000000..eda9f7e --- /dev/null +++ b/script_background.js @@ -0,0 +1,40 @@ +// ALERT TIMER +// time between alerts is controlled by config.alert.frequency +let time=0; +let timer = setInterval(()=>{ + time++ +},1000); + +chrome.runtime.onMessage.addListener((request, sender, sendResponse)=>{ + console.log(request); + flag = request.message.flag; + console.log(flag) + switch (flag) { + case "alert": + handleAlert(request); + case "get": + handleGet(request, sendResponse); + } + sendResponse("This is a mo'fuckin response") +}) + +function handleAlert({message}){ + console.log('handling alert') + alert = new Audio(chrome.runtime.getURL(`./assets/sounds/alert${message.option.sound}.mp3`)); + if( + alert && + message.option.frequency > 0 && + time>message.option.frequency + ){alert.play()} +} + +function handleGet({message}, sendResponse){ + console.log('handling get'); + const file = chrome.runtime.getURL('./toolbar.html'); + fetch(file) + .then((res) => { + console.log("RESPIGGITY SPONSE!") + console.log(res); + sendResponse("biggy"); + }) //assuming file contains json +} \ No newline at end of file diff --git a/script_foreground.js b/script_foreground.js new file mode 100644 index 0000000..97ffc24 --- /dev/null +++ b/script_foreground.js @@ -0,0 +1,64 @@ +let config = { + speed: 5000, + alert: { + sound:1, + frequency:1 + }, + watch: true +} + +chrome.runtime.onMessage.addListener(function(message, sender, sendResponse){ + console.log('message recieved','---------'); + console.log(message, sender, sendResponse); +}); + +function appendTool(html){ + chrome.runtime.sendMessage({message:{flag:"get", option:"toolbar.html"}}) + + + /* ADD HTML BUTTONS */ + var header = document.querySelector('.p-ia__view_header__spacer'); + header.innerHTML = "
START
STOP
"; + var start = document.querySelector('#start-timer'); + var stop = document.querySelector('#stop-timer'); + var alert = document.querySelector('#alert'); + var options = document.querySelector('#options'); + var timer; + + + start.addEventListener('click', function(){ + start.style.display = 'none'; + config.watch = true; + stop.style.display = 'inline-block'; + console.log('clicking Refresh every '+config.speed+' milliseconds'); + timer = setInterval(function(){ + var refresh_btn = document.querySelectorAll('[data-qa-action-id="refresh-queue"]')[0]; + if(refresh_btn){refresh_btn.click()}; + if(newQuestion()){ + chrome.runtime.sendMessage({message:{flag:"alert", option:config.alert}}); + config.watch = false; + }; + }, config.speed); + return timer; + }) + + stop.addEventListener('click', function(){ + stop.style.display = 'none'; + start.style.display = 'inline-block'; + clearInterval(timer); + + }) + + chrome.runtime.sendMessage({message:{flag:"alert", option:config.alert}}); +} + +function newQuestion(){ + let search = document.body.innerHTML.search('AVAILABLE QUESTIONS'); + if(search!==-1){ + return true; + } else { + return false; + } +} + +window.addEventListener('load', appendTool) diff --git a/styles.css b/styles.css new file mode 100644 index 0000000..66bbdd6 --- /dev/null +++ b/styles.css @@ -0,0 +1,23 @@ + +.cusBut { + border-radius: 5px; + line-height: 1.6; + border: 2px solid #dddddd; + width: 75px; + height: 30px; + margin: 1rem; + float: right; + text-align: center; + color:white; +} +#start-timer { + background-color: #91d68b; +} +#stop-timer { + background-color: #E70002; + display:none; +} +#alert { + display: none; + background-color: #6abdd7; +} diff --git a/toolbar.html b/toolbar.html new file mode 100644 index 0000000..91e873b --- /dev/null +++ b/toolbar.html @@ -0,0 +1,4 @@ + +
START
+
STOP
+