1
0
mirror of https://github.com/elisspace/AskAssist.git synced 2026-08-29 15:33:47 +00:00

first commit

This commit is contained in:
Jeremy Dixon
2021-01-17 21:25:11 -06:00
commit 18f1f240bc
16 changed files with 180 additions and 0 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

21
LICENSE Normal file
View File

@@ -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.

2
README.md Normal file
View File

@@ -0,0 +1,2 @@
# AskBcsAssistant
A small chrome plugin for managing a work slack

BIN
assets/.DS_Store vendored Normal file

Binary file not shown.

BIN
assets/icons/icon128.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

BIN
assets/icons/icon16.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
assets/icons/icon48.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

BIN
assets/images/gear.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

BIN
assets/sounds/alert0.mp3 Normal file

Binary file not shown.

BIN
assets/sounds/alert1.mp3 Normal file

Binary file not shown.

BIN
assets/sounds/alert2.mp3 Normal file

Binary file not shown.

26
manifest.json Normal file
View File

@@ -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
}

40
script_background.js Normal file
View File

@@ -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
}

64
script_foreground.js Normal file
View File

@@ -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 = "<select class='cusBut' id='alert_select'>ALERT</select><div class='cusBut' id='start-timer'>START</div><div class='cusBut' id='stop-timer'>STOP</div><div class='cusBut' id='options'></div>";
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('<b data-stringify-type="bold">AVAILABLE QUESTIONS</b>');
if(search!==-1){
return true;
} else {
return false;
}
}
window.addEventListener('load', appendTool)

23
styles.css Normal file
View File

@@ -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;
}

4
toolbar.html Normal file
View File

@@ -0,0 +1,4 @@
<select class='cusBut' id='alert_select'>ALERT</select>
<div class='cusBut' id='start-timer'>START</div>
<div class='cusBut' id='stop-timer'>STOP</div>
<div class='cusBut' id='options'></div>