Skip to content

Commit 98acc67

Browse files
all the changes for chrome extension 1.0.0 (#7)
1 parent b37e956 commit 98acc67

17 files changed

+380
-348
lines changed
113 KB
Binary file not shown.
24.3 KB
Binary file not shown.
41.7 KB
Binary file not shown.
76.4 KB
Binary file not shown.

chrome-extension/background.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// Event listener for extension installation
22
chrome.runtime.onInstalled.addListener(function (details) {
3-
if (details.reason === "install") {
4-
// Open options/index.html file in a new tab
5-
chrome.tabs.create({ url: "options/index.html?justInstalled=true" });
6-
}
3+
if (details.reason === "install") {
4+
// Open options/index.html file in a new tab
5+
chrome.tabs.create({ url: "options/index.html?justInstalled=true" });
6+
}
77
});
88

99
// Event listener for extension icon click
1010
chrome.action.onClicked.addListener(function () {
11-
// Open options/index.html file in a new tab
12-
chrome.tabs.create({ url: "options/index.html" });
11+
// Open options/index.html file in a new tab
12+
chrome.tabs.create({ url: "options/index.html" });
1313
});

chrome-extension/confetti.js

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,7 @@
22
!(function (window, module) {
33
// source content
44
(function main(global, module, isWorker, workerSize) {
5-
var canUseWorker = !!(
6-
global.Worker &&
7-
global.Blob &&
8-
global.Promise &&
9-
global.OffscreenCanvas &&
10-
global.OffscreenCanvasRenderingContext2D &&
11-
global.HTMLCanvasElement &&
12-
global.HTMLCanvasElement.prototype.transferControlToOffscreen &&
13-
global.URL &&
14-
global.URL.createObjectURL);
5+
var canUseWorker = false;
156

167
function noop() {}
178

@@ -439,7 +430,7 @@
439430
var isLibCanvas = !canvas;
440431
var allowResize = !!prop(globalOpts || {}, 'resize');
441432
var globalDisableForReducedMotion = prop(globalOpts, 'disableForReducedMotion', Boolean);
442-
var shouldUseWorker = canUseWorker && !!prop(globalOpts || {}, 'useWorker');
433+
var shouldUseWorker = false;
443434
var worker = shouldUseWorker ? getWorker() : null;
444435
var resizer = isLibCanvas ? setCanvasWindowSize : setCanvasRectSize;
445436
var initialized = (canvas && worker) ? !!canvas.__confetti_initialized : false;

chrome-extension/content.js

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@
1414
(async function () {
1515
"use strict";
1616

17-
function loadAudioInIframe(soundObj) { // weird thing to get around college board not allowing external audio sources to be played
18-
let iframe = document.createElement('iframe')
19-
iframe.id = "audioIframe"
20-
iframe.src = chrome.runtime.getURL('/iframe/audioPlayerIframe.html');
21-
iframe.allow = "autoplay"
17+
function loadAudioInIframe(soundObj) {
18+
// weird thing to get around college board not allowing external audio sources to be played
19+
let iframe = document.createElement("iframe");
20+
iframe.id = "audioIframe";
21+
iframe.src = chrome.runtime.getURL("/iframe/audioPlayerIframe.html");
22+
iframe.allow = "autoplay";
2223
iframe.style = `
2324
position: fixed;
2425
top: 0;
@@ -27,39 +28,41 @@
2728
height: 0;
2829
`;
2930
iframe.frameBorder = 0;
30-
iframe.scrolling = 'no';
31+
iframe.scrolling = "no";
3132

32-
iframe.addEventListener('load', () => {
33-
iframe.contentWindow.postMessage({sounds: soundObj, message: "setup"}, '*');
33+
iframe.addEventListener("load", () => {
34+
iframe.contentWindow.postMessage({ sounds: soundObj, message: "setup" }, "*");
3435
});
3536

3637
document.body.appendChild(iframe);
3738
}
3839

39-
function playSoundInFrame(score){
40-
let iframe = document.getElementById("audioIframe")
41-
iframe.contentWindow.postMessage({message: "score", score: score}, "*")
40+
function playSoundInFrame(score) {
41+
let iframe = document.getElementById("audioIframe");
42+
iframe.contentWindow.postMessage({ message: "score", score: score }, "*");
4243
}
4344

44-
function getObjWithId(array, id){
45-
for (let obj of array){
46-
if (obj.id === id){
47-
return obj
45+
function getObjWithId(array, id) {
46+
for (let obj of array) {
47+
if (obj.id === id) {
48+
return obj;
4849
}
4950
}
51+
return null;
5052
}
5153

52-
const selectSoundsObj = await chrome.storage.local.get("selectedSounds") // get the response from storage
53-
const selectedSounds = selectSoundsObj.selectedSounds
54-
const soundStorage = await chrome.storage.local.get("sounds") // get the response from storage
55-
const soundArray = soundStorage.sounds
56-
let sounds = {}
54+
const selectSoundsObj = await chrome.storage.local.get("selectedSounds"); // get the response from storage
55+
const selectedSounds = selectSoundsObj.selectedSounds;
56+
const soundStorage = await chrome.storage.local.get("sounds"); // get the response from storage
57+
const soundArray = soundStorage.sounds;
58+
let sounds = {};
5759

58-
for (let score in selectedSounds) { // basically transfering this new format to the old format
59-
sounds[score] = getObjWithId(soundArray, selectedSounds[score]).URL
60+
for (let score in selectedSounds) {
61+
// basically transfering this new format to the old format
62+
sounds[score] = getObjWithId(soundArray, selectedSounds[score])?.URL || "";
6063
}
61-
console.log(sounds)
62-
loadAudioInIframe(sounds)
64+
// console.log(sounds);
65+
loadAudioInIframe(sounds);
6366

6467
// Grab all of the boxes that contain scores
6568
document.body.style.opacity = "0%"; // Hide the entire page until we can hide the scores themselves
@@ -86,12 +89,12 @@
8689
ccontainer.parentNode.parentNode.style.cursor = "pointer"; // Makes the mouse display a pointer when you hover over the place the score should be
8790
ccontainer.parentNode.children[1].style.pointerEvents = "none"; // Make the sidebar not clickable
8891

89-
const clickListener = (e) => {
92+
const clickListener = (e) => {
9093
e.stopPropagation();
9194
const container = ccontainer.querySelector(".apscores-badge.apscores-badge-score"); // Have to do this again because reference gets messed
9295
const scoreNode = container.childNodes[1]; // Grab the text box that holds the score number
9396
const score = parseInt(scoreNode.nodeValue); // Get the score as a number (not a string)
94-
playSoundInFrame(score)
97+
playSoundInFrame(score);
9598
if (score >= 3) {
9699
const { left, top } = ccontainer.getBoundingClientRect();
97100

chrome-extension/icons/128.png

-2.36 KB
Loading

chrome-extension/icons/48.png

5.74 KB
Loading

chrome-extension/icons/512.png

-30.7 KB
Loading

0 commit comments

Comments
 (0)