Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
f4b87628ea | |||
2f65b6699b | |||
9af668ceac | |||
e7dd54107c | |||
4c123cd78d | |||
faeffc41e6 | |||
40a469de0e | |||
26ba99b803 | |||
8eb336df03 | |||
a849d56204 |
3
.eslintignore
Normal file
3
.eslintignore
Normal file
@ -0,0 +1,3 @@
|
||||
node_modules
|
||||
web-ext-artifacts
|
||||
vendor
|
20
.eslintrc.json
Normal file
20
.eslintrc.json
Normal file
@ -0,0 +1,20 @@
|
||||
{
|
||||
"env": {
|
||||
"browser": true,
|
||||
"es6": true,
|
||||
"commonjs": true
|
||||
},
|
||||
"extends": [
|
||||
"standard"
|
||||
],
|
||||
"globals": {
|
||||
"Atomics": "readonly",
|
||||
"SharedArrayBuffer": "readonly"
|
||||
},
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 2018
|
||||
},
|
||||
"rules": {
|
||||
"no-undef": 2
|
||||
}
|
||||
}
|
BIN
assets/icons/128.png
Normal file
BIN
assets/icons/128.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.0 KiB |
@ -1,44 +1,63 @@
|
||||
console.log('SOMtodayn\'t background script loaded')
|
||||
|
||||
// Read array from local storage
|
||||
function getSlogans() {
|
||||
var slogans;
|
||||
if (localStorage.getItem('SOMtodayntSlogans') != null) {
|
||||
slogans = JSON.parse(localStorage.getItem('SOMtodayntSlogans'));
|
||||
} else {
|
||||
var slogans = [ "Welkom bij SOMtodayn't" ]
|
||||
localStorage.setItem('SOMtodayntSlogans', JSON.stringify(slogans));
|
||||
}
|
||||
return slogans;
|
||||
function getSlogans () {
|
||||
let slogans
|
||||
let tonight
|
||||
|
||||
if (localStorage.getItem('SOMtodayntSlogans') != null) {
|
||||
slogans = JSON.parse(localStorage.getItem('SOMtodayntSlogans'))
|
||||
tonight = JSON.parse(localStorage.getItem('SOMtonight'))
|
||||
} else {
|
||||
slogans = ["Welkom bij SOMtodayn't"]
|
||||
tonight = true
|
||||
localStorage.setItem('SOMtodayntSlogans', JSON.stringify(slogans))
|
||||
localStorage.setItem('SOMtonight', JSON.stringify(tonight))
|
||||
}
|
||||
|
||||
return [
|
||||
tonight,
|
||||
slogans
|
||||
]
|
||||
}
|
||||
|
||||
// Update array in local storage
|
||||
function setSlogans(array) {
|
||||
localStorage.setItem('SOMtodayntSlogans', JSON.stringify(array));
|
||||
return true;
|
||||
function setSlogans (array) {
|
||||
localStorage.setItem('SOMtodayntSlogans', JSON.stringify(array))
|
||||
return true
|
||||
}
|
||||
|
||||
function setTonight (value) {
|
||||
localStorage.setItem('SOMtonight', JSON.stringify(value))
|
||||
}
|
||||
|
||||
// Handle requests
|
||||
function handleMessage(request, sender, sendResponse) {
|
||||
var response;
|
||||
// DEBUG // console.log(sender);
|
||||
// DEBUG // console.log("Request: " + request.type)
|
||||
switch (request.type) {
|
||||
case 'get':
|
||||
response = getSlogans();
|
||||
break;
|
||||
function handleMessage (request, sender, sendResponse) {
|
||||
let response
|
||||
// DEBUG // console.log(sender);
|
||||
// DEBUG // console.log("Request: " + request.type)
|
||||
switch (request.type) {
|
||||
case 'get':
|
||||
response = getSlogans()
|
||||
break
|
||||
|
||||
case 'set':
|
||||
response = setSlogans(request.value);
|
||||
break;
|
||||
}
|
||||
// Send response to either the content script or popup
|
||||
if (sender.tab) {
|
||||
browser.tabs.sendMessage(sender.tab.id, response);
|
||||
} else {
|
||||
sendResponse({response: response});
|
||||
}
|
||||
// DEBUG // console.log("Response: " + response)
|
||||
case 'setSlogans':
|
||||
response = setSlogans(request.value)
|
||||
break
|
||||
|
||||
case 'setTonight':
|
||||
response = setTonight(request.value)
|
||||
break
|
||||
}
|
||||
// Send response to either the content script or popup
|
||||
if (sender.tab) {
|
||||
browser.tabs.sendMessage(sender.tab.id, response)
|
||||
} else {
|
||||
sendResponse({
|
||||
response: response
|
||||
})
|
||||
}
|
||||
// DEBUG // console.log("Response: " + response)
|
||||
}
|
||||
|
||||
browser.runtime.onMessage.addListener(handleMessage);
|
||||
|
||||
browser.runtime.onMessage.addListener(handleMessage)
|
||||
|
236
content/css/index.css
Normal file
236
content/css/index.css
Normal file
@ -0,0 +1,236 @@
|
||||
/* Global styles */
|
||||
body {
|
||||
background-color: #121212;
|
||||
}
|
||||
a {
|
||||
color: #01a299;
|
||||
}
|
||||
|
||||
/* Login screen */
|
||||
/* Background */
|
||||
.stpanel section div#logo figure.figurelogo {
|
||||
filter: grayscale(100%) brightness(400%);
|
||||
}
|
||||
.stpanel section {
|
||||
background-color: #121212;
|
||||
}
|
||||
/* Marketing text */
|
||||
.stpanel section div#marketing {
|
||||
color: #e1e1e1;
|
||||
}
|
||||
/* Form container and messages */
|
||||
.stpanel section div.form--holder .stpanel--error--message, .stpanel section div.form--holder form {
|
||||
color: #e1e1e1;
|
||||
box-shadow: unset;
|
||||
background-color: #1E1E1E;
|
||||
}
|
||||
.stpanel .loader--dot1, .stpanel .loader--dot2, .stpanel .loader--dot3, .stpanel .loader--dot4 {
|
||||
background-color: #01A299;
|
||||
}
|
||||
.stpanel--loader {
|
||||
background-color: unset;
|
||||
}
|
||||
.stpanel--links a {
|
||||
color: #017374;
|
||||
}
|
||||
.stpanel--links a:hover {
|
||||
color: #00B3A6;
|
||||
}
|
||||
/* Slogan */
|
||||
.stpanel section div#slogan span:last-of-type {
|
||||
color: #01A299;
|
||||
}
|
||||
/* Inputs */
|
||||
.stpanel .form--input input {
|
||||
color: #e1e1e1;
|
||||
border-color: #e1e1e1;
|
||||
background-color: #383838;
|
||||
}
|
||||
.stpanel .form--input input:focus {
|
||||
color: #ebebeb;
|
||||
border-color: #70EFDE;
|
||||
}
|
||||
.stpanel .form--input.state-disabled input {
|
||||
background-color: #01A299;
|
||||
border-color: #01A299;
|
||||
color: #ebebeb;
|
||||
}
|
||||
.stpanel .form--input i {
|
||||
color: #ebebeb;
|
||||
}
|
||||
.stpanel .form--input i:hover {
|
||||
color: #a5a5a5;
|
||||
}
|
||||
/* Checkbox */
|
||||
.stpanel .form--checkbox:focus i, .stpanel .form--checkbox:hover i, .stpanel .form--radio:focus i, .stpanel .form--radio:hover i, .stpanel .form--select:focus select, .stpanel .form--select:hover select, .stpanel--screensaver .form--select:focus select, .stpanel--screensaver .form--select:hover select {
|
||||
border-color: #01A299;
|
||||
}
|
||||
.stpanel .form--checkbox input + i::after{
|
||||
color: #e1e1e1;
|
||||
}
|
||||
.stpanel .form--checkbox input:checked + i, .stpanel .form--radio input:checked + i {
|
||||
background-color: #01A299;
|
||||
border-color: #01A299;
|
||||
}
|
||||
/* Buttons */
|
||||
.button--stpanel, button.button--stpanel, input[type="submit"].button--stpanel {
|
||||
color: #01A299;
|
||||
}
|
||||
.stpanel section div#marketing a.btn, .stpanel section div.form--holder .stpanel--error--message a.button--stpanel, .stpanel section div.form--holder form a.button--stpanel, .stpanel--meldingen a.button--stpanel, .stpanel--screensaver section div.form--holder .stpanel--error--message a.button--stpanel, .stpanel--screensaver section div.form--holder form a.button--stpanel {
|
||||
border-color: #01A299;
|
||||
color: #01A299!important;
|
||||
}
|
||||
.stpanel section div#marketing a.btn:hover, .button--stpanel:active, .button--stpanel:focus, .button--stpanel:hover, .stpanel section div.form--holder .stpanel--error--message a.button--stpanel:active, .stpanel section div.form--holder .stpanel--error--message a.button--stpanel:focus, .stpanel section div.form--holder .stpanel--error--message a.button--stpanel:hover, .stpanel section div.form--holder form a.button--stpanel:active, .stpanel section div.form--holder form a.button--stpanel:focus, .stpanel section div.form--holder form a.button--stpanel:hover, .stpanel--meldingen a.button--stpanel:active, .stpanel--meldingen a.button--stpanel:focus, .stpanel--meldingen a.button--stpanel:hover, .stpanel--screensaver section div.form--holder .stpanel--error--message a.button--stpanel:active, .stpanel--screensaver section div.form--holder .stpanel--error--message a.button--stpanel:focus, .stpanel--screensaver section div.form--holder .stpanel--error--message a.button--stpanel:hover, .stpanel--screensaver section div.form--holder form a.button--stpanel:active, .stpanel--screensaver section div.form--holder form a.button--stpanel:focus, .stpanel--screensaver section div.form--holder form a.button--stpanel:hover, button.button--stpanel:active, button.button--stpanel:focus, button.button--stpanel:hover, input[type="submit"].button--stpanel:active, input[type="submit"].button--stpanel:focus, input[type="submit"].button--stpanel:hover {
|
||||
background:#01A299;
|
||||
color: #e1e1e1!important;
|
||||
}
|
||||
/* Footer */
|
||||
footer > span {
|
||||
color: #e1e1e1;
|
||||
}
|
||||
|
||||
/* Main screen */
|
||||
/* Header */
|
||||
span.logo {
|
||||
opacity: 0.75;
|
||||
}
|
||||
#header-wrapper {
|
||||
background-color: #1E1E1E;
|
||||
}
|
||||
#header-wrapper a {
|
||||
color: #a5a5a5!important;
|
||||
}
|
||||
#header-wrapper a:hover {
|
||||
color: #e1e1e1!important;
|
||||
opacity: 1;
|
||||
}
|
||||
span.header {
|
||||
color: unset;
|
||||
}
|
||||
#user img {
|
||||
display: none;
|
||||
}
|
||||
#user span.header {
|
||||
color: unset;
|
||||
}
|
||||
span#inbox-counter {
|
||||
background-color: #01A299;
|
||||
color: #121212!important;
|
||||
}
|
||||
|
||||
/* Content Window */
|
||||
/* Main menu */
|
||||
#main-menu a.active, #main-menu a.active:hover {
|
||||
background-color: #01A299;
|
||||
color: #e1e1e1!important;
|
||||
}
|
||||
#main-menu a {
|
||||
background-color: #232323;
|
||||
color: #a5a5a5!important;
|
||||
}
|
||||
#main-menu a:hover {
|
||||
background-color: #292929;
|
||||
color: #e1e1e1!important;
|
||||
}
|
||||
#main-menu-bottom {
|
||||
background-color: #01A299;
|
||||
}
|
||||
#content {
|
||||
box-shadow: unset;
|
||||
}
|
||||
/* Panels */
|
||||
#master-panel, #master-panel .panel-header {
|
||||
background-color: #1E1E1E;
|
||||
border: unset;
|
||||
color: #e1e1e1;
|
||||
}
|
||||
.panel-header h2, #detail-panel h2, #detail-panel h3 {
|
||||
color: #e1e1e1;
|
||||
}
|
||||
#master-panel h2, h1 {
|
||||
color: #e1e1e1;
|
||||
}
|
||||
#master-panel .sub {
|
||||
color: #a5a5a5;
|
||||
}
|
||||
div#detail-panel-wrapper {
|
||||
background-color: #232323;
|
||||
}
|
||||
#master-panel ~ #detail-panel-wrapper, #content {
|
||||
border: unset!important;
|
||||
}
|
||||
/* Date and type tags */
|
||||
#master-panel .date div, .pauze, .roster-table-header .day .huiswerk-items, .uurNummer, .type {
|
||||
background-color: #2C2C2C!important;
|
||||
color: #e1e1e1!important;
|
||||
border-color: #a5a5a5!important;
|
||||
}
|
||||
#master-panel .date div p.date-day, #master-panel .date div p.date-month, #master-panel .date span {
|
||||
color: #e1e1e1!important;
|
||||
}
|
||||
#master-panel .date div {
|
||||
border-right: 0px !important;
|
||||
margin: 0 0 0 -40px !important;
|
||||
padding: 5px !important;
|
||||
}
|
||||
#master-panel .date div p.date-day {
|
||||
background: unset;
|
||||
}
|
||||
/* Top-right buttons */
|
||||
.ribbon .chk.checked, .ribbon .chk:hover, .ribbon.chk.checked, .yellow.ribbon a {
|
||||
color:#e1e1e1;
|
||||
border-bottom: 3px solid #00C4B4;
|
||||
background-color: unset!important;
|
||||
}
|
||||
.ribbon .chk, .ribbon .chk.checked:hover{
|
||||
color: #a5a5a5;
|
||||
border-color: #019592;
|
||||
}
|
||||
.yellow.ribbon span {
|
||||
color: #a5a5a5;
|
||||
}
|
||||
/* Box items */
|
||||
.box {
|
||||
background-color: #2C2C2C;
|
||||
color: #e1e1e1;
|
||||
border: unset;
|
||||
margin-top: 5px;
|
||||
}
|
||||
.m-element {
|
||||
color: #e1e1e1;
|
||||
border: unset!important;
|
||||
}
|
||||
.m-element:hover {
|
||||
background-color: #2C2C2C;
|
||||
}
|
||||
.m-wrapper.active {
|
||||
margin: 0;
|
||||
background:#333333;
|
||||
}
|
||||
|
||||
.section .block {
|
||||
background: #2c2c2c;
|
||||
border: unset;
|
||||
}
|
||||
.blue.ribbon p, .blue.ribbon .icon-check, .blue.ribbon .icon-check-empty{
|
||||
color: #e1e1e1 !important;
|
||||
}
|
||||
.huiswerkbijlage .simple-view, .section a.right {
|
||||
background: #333333;
|
||||
color: #e1e1e1;
|
||||
border-radius: 3px;
|
||||
border: unset;
|
||||
}
|
||||
.huiswerkbijlage .simple-view .bijlage-label, .section a.right {
|
||||
color: #a5a5a5;
|
||||
}
|
||||
.huiswerkbijlage .simple-view:hover .bijlage-label, .section a.right:hover {
|
||||
color: #e1e1e1;
|
||||
background: unset;
|
||||
border: unset;
|
||||
}
|
||||
/* Ions */
|
||||
.icon-geen-van-beide, .icon-huiswerk, .icon-leermiddelen, .icon-maatregel, .icon-studiewijzer, .icon-toets {
|
||||
background-color: #01A299;
|
||||
color: #121212!important;
|
||||
}
|
@ -1,47 +1,63 @@
|
||||
console.log('Somtoday\'nt content script active');
|
||||
console.log('Somtoday\'nt content script active')
|
||||
|
||||
function changeSlogan(message)
|
||||
{
|
||||
// Select random slogan
|
||||
console.log(`Loaded ${message.length} slogans`);
|
||||
if (message.length >= 1) {
|
||||
var random = Math.floor(Math.random() * message.length);
|
||||
var sloganText = message[random].toLowerCase();
|
||||
console.log(`Slogan changed to: ${sloganText}`);
|
||||
} else {
|
||||
var sloganText = "welkom bij somtodayn't";
|
||||
console.log('No slogans found')
|
||||
function changeSlogan (message) {
|
||||
if (message === 'reload') {
|
||||
location.reload()
|
||||
} else {
|
||||
const tonight = message[0]
|
||||
const slogans = message[1]
|
||||
|
||||
// Set theme
|
||||
console.log(tonight)
|
||||
if (tonight) {
|
||||
const cssUrl = browser.runtime.getURL('content/css/index.css')
|
||||
const cssTag = `<link rel='stylesheet' href='${cssUrl}'>`
|
||||
document.head.innerHTML += cssTag
|
||||
}
|
||||
|
||||
|
||||
// Select random slogan
|
||||
console.log(`Loaded ${slogans.length} slogans`)
|
||||
let sloganText
|
||||
|
||||
if (slogans.length >= 1) {
|
||||
const random = Math.floor(Math.random() * slogans.length)
|
||||
sloganText = slogans[random].toLowerCase()
|
||||
console.log(`Slogan changed to: ${sloganText}`)
|
||||
} else {
|
||||
sloganText = "welkom bij somtodayn't"
|
||||
console.log('No slogans found')
|
||||
}
|
||||
|
||||
// Split the slogan into array
|
||||
var sloganArray = sloganText.split(" ");
|
||||
var slogan = {
|
||||
white: '',
|
||||
blue: ''
|
||||
};
|
||||
|
||||
const sloganArray = sloganText.split(' ')
|
||||
const slogan = {
|
||||
white: '',
|
||||
blue: ''
|
||||
}
|
||||
|
||||
// Set the last word in the array to be blue
|
||||
if (sloganArray.length > 1) {
|
||||
slogan.blue = sloganArray.pop();
|
||||
for (let index = 0; index < sloganArray.length; index++) {
|
||||
slogan.white = slogan.white + sloganArray[index] + " ";
|
||||
}
|
||||
slogan.blue = sloganArray.pop()
|
||||
for (let index = 0; index < sloganArray.length; index++) {
|
||||
slogan.white = slogan.white + sloganArray[index] + ' '
|
||||
}
|
||||
} else {
|
||||
slogan.white = sloganArray;
|
||||
slogan.white = sloganArray
|
||||
}
|
||||
|
||||
|
||||
// Edit HTML
|
||||
document.getElementById('slogan').innerHTML =
|
||||
`<span class="white block">${slogan.white}</span>
|
||||
<span>${slogan.blue}</span>`
|
||||
;
|
||||
document.getElementById('slogan').innerHTML =
|
||||
`<span class="white block">${slogan.white}</span><span>${slogan.blue}</span>`
|
||||
|
||||
// Add a little credit
|
||||
document.querySelectorAll('footer > span')[0].innerHTML = "Somtodayn't is een add-on door McArn.";
|
||||
document.querySelectorAll('footer > span')[0].innerHTML = "Somtodayn't is een add-on door McArn."
|
||||
}
|
||||
}
|
||||
|
||||
// Send request to background script
|
||||
browser.runtime.sendMessage({ type: "get"});
|
||||
browser.runtime.sendMessage({
|
||||
type: 'get'
|
||||
})
|
||||
|
||||
// Receive response from background script
|
||||
browser.runtime.onMessage.addListener(changeSlogan);
|
||||
browser.runtime.onMessage.addListener(changeSlogan)
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
"manifest_version": 2,
|
||||
"name": "SOMtodayn't",
|
||||
"version": "1.15",
|
||||
"author": "McArn",
|
||||
"version": "1.22.0",
|
||||
"author": "Arne van Iterson",
|
||||
|
||||
"description": "Changes the slogan on the login page of the school management system SOMtoday.",
|
||||
|
||||
@ -12,6 +12,11 @@
|
||||
"id": "arne@arnweb.nl"
|
||||
}
|
||||
},
|
||||
|
||||
"permissions": [
|
||||
"tabs",
|
||||
"storage"
|
||||
],
|
||||
|
||||
"icons": {
|
||||
"25" : "assets/icons/25.png",
|
||||
@ -21,7 +26,10 @@
|
||||
|
||||
"background": {
|
||||
"persistent": true,
|
||||
"scripts": ["background/js/index.js"]
|
||||
"scripts": [
|
||||
"vendor/browser-polyfill.js",
|
||||
"background/js/index.js"
|
||||
]
|
||||
},
|
||||
|
||||
"browser_action": {
|
||||
@ -33,10 +41,17 @@
|
||||
"default_popup": "popup/html/index.html"
|
||||
},
|
||||
|
||||
"web_accessible_resources": [
|
||||
"content/css/index.css"
|
||||
],
|
||||
|
||||
"content_scripts": [
|
||||
{
|
||||
"matches": ["*://*.somtoday.nl/*"],
|
||||
"js": ["content/js/index.js"]
|
||||
"js": [
|
||||
"vendor/browser-polyfill.js",
|
||||
"content/js/index.js"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
|
5766
package-lock.json
generated
5766
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
26
package.json
Normal file
26
package.json
Normal file
@ -0,0 +1,26 @@
|
||||
{
|
||||
"name": "somtodaynt",
|
||||
"version": "1.22.0",
|
||||
"description": "Simple browser plugin for changing the slogan of SOMtoday",
|
||||
"main": "./content/js/index.js",
|
||||
"dependencies": {
|
||||
"web-ext": "^5.4.1",
|
||||
"webextension-polyfill": "^0.7.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "^7.15.0",
|
||||
"eslint-config-standard": "^16.0.2",
|
||||
"eslint-plugin-import": "^2.22.1",
|
||||
"eslint-plugin-node": "^11.1.0",
|
||||
"eslint-plugin-promise": "^4.2.1"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://gitea.arnweb.nl/arne/somtodaynt.git"
|
||||
},
|
||||
"author": "Arne van Iterson",
|
||||
"license": "ISC"
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<script type="application/javascript" src="/vendor/browser-polyfill.js"></script>
|
||||
<link href="https://fonts.googleapis.com/css?family=Bree+Serif&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="../css/index.css">
|
||||
</head>
|
||||
@ -9,16 +10,24 @@
|
||||
<div>
|
||||
<h2>SOMtodayn't</h2>
|
||||
</div>
|
||||
|
||||
<h3>Slogan toevoegen</h3>
|
||||
<h6>Het laatste woord van de slogan wordt blauw.</h6>
|
||||
<form id="sloganForm">
|
||||
<input type="text" placeholder="Nieuwe slogan">
|
||||
<button type="submit">Toevoegen</button>
|
||||
</form>
|
||||
|
||||
<h3>SOMtonight™</h3>
|
||||
<h6>Donkere modus voor SOMtoday</h6>
|
||||
<input type="checkbox" name="tonight" id="tonight">
|
||||
<label for="tonight">SOMtonight™ gebruiken</label>
|
||||
|
||||
<h3>Bestaande slogans</h3>
|
||||
<h6>Klik op een slogan om deze te verwijderen.</h6>
|
||||
<div id="sloganList">
|
||||
</div>
|
||||
|
||||
<span class="footer">By McArn - 2019</span>
|
||||
<script src="../js/index.js"></script>
|
||||
</body>
|
||||
|
@ -1,75 +1,103 @@
|
||||
console.log("SOMtodayn't popup loaded.");
|
||||
var request;
|
||||
var response;
|
||||
console.log("SOMtodayn't popup loaded.")
|
||||
let request
|
||||
|
||||
// Get slogans from background script
|
||||
request = browser.runtime.sendMessage({
|
||||
type: "get"
|
||||
});
|
||||
request.then(function(message) {
|
||||
var sloganArray = message.response;
|
||||
// DEBUG // console.log(message.response);
|
||||
type: 'get'
|
||||
})
|
||||
request.then(function (message) {
|
||||
const darkmode = message.response[0]
|
||||
const sloganArray = message.response[1]
|
||||
|
||||
// Add a slogan to the array
|
||||
function addSlogan(value) {
|
||||
sloganArray.push(value);
|
||||
updateSlogans(sloganArray);
|
||||
}
|
||||
// Add a slogan to the array
|
||||
function addSlogan (value) {
|
||||
sloganArray.push(value)
|
||||
updateSlogans(sloganArray)
|
||||
}
|
||||
|
||||
// Remove a slogan from the array
|
||||
function removeSlogan(id) {
|
||||
var array = [];
|
||||
if (sloganArray.length > 1) {
|
||||
for (let index = 0; index < sloganArray.length; index++) {
|
||||
const element = sloganArray[index];
|
||||
if (index != id) {
|
||||
array.push(element);
|
||||
}
|
||||
}
|
||||
updateSlogans(array);
|
||||
} else {
|
||||
window.alert("U kunt de laatste slogan niet verwijderen.");
|
||||
// Remove a slogan from the array
|
||||
function removeSlogan (id) {
|
||||
const array = []
|
||||
if (sloganArray.length > 1) {
|
||||
for (let index = 0; index < sloganArray.length; index++) {
|
||||
const element = sloganArray[index]
|
||||
if (index !== id) {
|
||||
array.push(element)
|
||||
}
|
||||
}
|
||||
updateSlogans(array)
|
||||
} else {
|
||||
window.alert('U kunt de laatste slogan niet verwijderen.')
|
||||
}
|
||||
}
|
||||
|
||||
// Send updated array to background script
|
||||
function updateSlogans(array) {
|
||||
request = browser.runtime.sendMessage({
|
||||
type: "set",
|
||||
value: array
|
||||
});
|
||||
request.then(function() {
|
||||
location.reload();
|
||||
}, handleError);
|
||||
// Send updated array to background script
|
||||
function updateSlogans (array) {
|
||||
request = browser.runtime.sendMessage({
|
||||
type: 'setSlogans',
|
||||
value: array
|
||||
})
|
||||
request.then(function () {
|
||||
location.reload()
|
||||
}, handleError)
|
||||
}
|
||||
|
||||
// Add event listener to checkbox
|
||||
const checkbox = document.getElementById('tonight')
|
||||
if (darkmode) {
|
||||
checkbox.checked = true
|
||||
}
|
||||
checkbox.addEventListener('click', function (event) {
|
||||
// Update value in local storage
|
||||
request = browser.runtime.sendMessage({
|
||||
type: 'setTonight',
|
||||
value: checkbox.checked
|
||||
})
|
||||
// Reload all SOMtoday tabs
|
||||
const reload = browser.tabs.query({})
|
||||
reload.then(logTabs, onError)
|
||||
})
|
||||
|
||||
// Find id of somtoday.nl tab
|
||||
function logTabs (tabs) {
|
||||
for (const tab of tabs) {
|
||||
// Match only tabs with url somtoday.nl
|
||||
if (tab.url.includes('somtoday.nl')) {
|
||||
browser.tabs.sendMessage(tab.id, 'reload')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add existing slogans to list items in the popup
|
||||
var sloganList = '';
|
||||
for (let index = 0; index < sloganArray.length; index++) {
|
||||
const element = sloganArray[index];
|
||||
sloganList = sloganList + `<ul>${element}</ul>`;
|
||||
}
|
||||
document.getElementById('sloganList').innerHTML = sloganList;
|
||||
// Handle query errors
|
||||
function onError (error) {
|
||||
console.log(`Error: ${error}`)
|
||||
}
|
||||
|
||||
// Get value for new slogan
|
||||
document.getElementById('sloganForm').addEventListener('submit', function(event) {
|
||||
event.preventDefault();
|
||||
addSlogan(event.target.children[0].value);
|
||||
event.target.children[0].value = '';
|
||||
});
|
||||
// Add existing slogans to list items in the popup
|
||||
let sloganList = ''
|
||||
for (let index = 0; index < sloganArray.length; index++) {
|
||||
const element = sloganArray[index]
|
||||
sloganList = sloganList + `<ul>${element}</ul>`
|
||||
}
|
||||
document.getElementById('sloganList').innerHTML = sloganList
|
||||
|
||||
// Add event listener to every list item for deleting slogans
|
||||
var listElements = document.querySelectorAll("div#sloganList > ul");
|
||||
for (let index = 0; index < listElements.length; index++) {
|
||||
const element = listElements[index];
|
||||
element.addEventListener("click", function() {
|
||||
removeSlogan(index);
|
||||
});
|
||||
}
|
||||
// Get value for new slogan
|
||||
document.getElementById('sloganForm').addEventListener('submit', function (event) {
|
||||
event.preventDefault()
|
||||
addSlogan(event.target.children[0].value)
|
||||
event.target.children[0].value = ''
|
||||
})
|
||||
|
||||
}, handleError);
|
||||
// Add event listener to every list item for deleting slogans
|
||||
const listElements = document.querySelectorAll('div#sloganList > ul')
|
||||
for (let index = 0; index < listElements.length; index++) {
|
||||
const element = listElements[index]
|
||||
element.addEventListener('click', function () {
|
||||
removeSlogan(index)
|
||||
})
|
||||
}
|
||||
}, handleError)
|
||||
|
||||
function handleError(error) {
|
||||
console.error(`SOMtodayn't Error: ${error}`);
|
||||
function handleError (error) {
|
||||
console.error(`SOMtodayn't Error: ${error}`)
|
||||
}
|
||||
|
||||
|
1187
vendor/browser-polyfill.js
vendored
Normal file
1187
vendor/browser-polyfill.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
vendor/browser-polyfill.js.map
vendored
Normal file
1
vendor/browser-polyfill.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user