Compare commits
No commits in common. "master" and "v1.20" have entirely different histories.
@ -1,3 +0,0 @@
|
|||||||
node_modules
|
|
||||||
web-ext-artifacts
|
|
||||||
vendor
|
|
@ -1,20 +0,0 @@
|
|||||||
{
|
|
||||||
"env": {
|
|
||||||
"browser": true,
|
|
||||||
"es6": true,
|
|
||||||
"commonjs": true
|
|
||||||
},
|
|
||||||
"extends": [
|
|
||||||
"standard"
|
|
||||||
],
|
|
||||||
"globals": {
|
|
||||||
"Atomics": "readonly",
|
|
||||||
"SharedArrayBuffer": "readonly"
|
|
||||||
},
|
|
||||||
"parserOptions": {
|
|
||||||
"ecmaVersion": 2018
|
|
||||||
},
|
|
||||||
"rules": {
|
|
||||||
"no-undef": 2
|
|
||||||
}
|
|
||||||
}
|
|
Binary file not shown.
Before Width: | Height: | Size: 6.0 KiB |
@ -1,63 +1,44 @@
|
|||||||
console.log('SOMtodayn\'t background script loaded')
|
console.log('SOMtodayn\'t background script loaded')
|
||||||
|
|
||||||
// Read array from local storage
|
// Read array from local storage
|
||||||
function getSlogans () {
|
function getSlogans() {
|
||||||
let slogans
|
var slogans;
|
||||||
let tonight
|
if (localStorage.getItem('SOMtodayntSlogans') != null) {
|
||||||
|
slogans = JSON.parse(localStorage.getItem('SOMtodayntSlogans'));
|
||||||
if (localStorage.getItem('SOMtodayntSlogans') != null) {
|
} else {
|
||||||
slogans = JSON.parse(localStorage.getItem('SOMtodayntSlogans'))
|
var slogans = [ "Welkom bij SOMtodayn't" ]
|
||||||
tonight = JSON.parse(localStorage.getItem('SOMtonight'))
|
localStorage.setItem('SOMtodayntSlogans', JSON.stringify(slogans));
|
||||||
} else {
|
}
|
||||||
slogans = ["Welkom bij SOMtodayn't"]
|
return slogans;
|
||||||
tonight = true
|
|
||||||
localStorage.setItem('SOMtodayntSlogans', JSON.stringify(slogans))
|
|
||||||
localStorage.setItem('SOMtonight', JSON.stringify(tonight))
|
|
||||||
}
|
|
||||||
|
|
||||||
return [
|
|
||||||
tonight,
|
|
||||||
slogans
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update array in local storage
|
// Update array in local storage
|
||||||
function setSlogans (array) {
|
function setSlogans(array) {
|
||||||
localStorage.setItem('SOMtodayntSlogans', JSON.stringify(array))
|
localStorage.setItem('SOMtodayntSlogans', JSON.stringify(array));
|
||||||
return true
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
function setTonight (value) {
|
|
||||||
localStorage.setItem('SOMtonight', JSON.stringify(value))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle requests
|
// Handle requests
|
||||||
function handleMessage (request, sender, sendResponse) {
|
function handleMessage(request, sender, sendResponse) {
|
||||||
let response
|
var response;
|
||||||
// DEBUG // console.log(sender);
|
// DEBUG // console.log(sender);
|
||||||
// DEBUG // console.log("Request: " + request.type)
|
// DEBUG // console.log("Request: " + request.type)
|
||||||
switch (request.type) {
|
switch (request.type) {
|
||||||
case 'get':
|
case 'get':
|
||||||
response = getSlogans()
|
response = getSlogans();
|
||||||
break
|
break;
|
||||||
|
|
||||||
case 'setSlogans':
|
case 'set':
|
||||||
response = setSlogans(request.value)
|
response = setSlogans(request.value);
|
||||||
break
|
break;
|
||||||
|
}
|
||||||
case 'setTonight':
|
// Send response to either the content script or popup
|
||||||
response = setTonight(request.value)
|
if (sender.tab) {
|
||||||
break
|
browser.tabs.sendMessage(sender.tab.id, response);
|
||||||
}
|
} else {
|
||||||
// Send response to either the content script or popup
|
sendResponse({response: response});
|
||||||
if (sender.tab) {
|
}
|
||||||
browser.tabs.sendMessage(sender.tab.id, response)
|
// DEBUG // console.log("Response: " + response)
|
||||||
} else {
|
|
||||||
sendResponse({
|
|
||||||
response: response
|
|
||||||
})
|
|
||||||
}
|
|
||||||
// DEBUG // console.log("Response: " + response)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
browser.runtime.onMessage.addListener(handleMessage)
|
browser.runtime.onMessage.addListener(handleMessage);
|
@ -1,236 +0,0 @@
|
|||||||
/* 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,63 +1,47 @@
|
|||||||
console.log('Somtoday\'nt content script active')
|
console.log('Somtoday\'nt content script active');
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
|
function changeSlogan(message)
|
||||||
|
{
|
||||||
// Select random slogan
|
// Select random slogan
|
||||||
console.log(`Loaded ${slogans.length} slogans`)
|
console.log(`Loaded ${message.length} slogans`);
|
||||||
let sloganText
|
if (message.length >= 1) {
|
||||||
|
var random = Math.floor(Math.random() * message.length);
|
||||||
if (slogans.length >= 1) {
|
var sloganText = message[random].toLowerCase();
|
||||||
const random = Math.floor(Math.random() * slogans.length)
|
console.log(`Slogan changed to: ${sloganText}`);
|
||||||
sloganText = slogans[random].toLowerCase()
|
|
||||||
console.log(`Slogan changed to: ${sloganText}`)
|
|
||||||
} else {
|
} else {
|
||||||
sloganText = "welkom bij somtodayn't"
|
var sloganText = "welkom bij somtodayn't";
|
||||||
console.log('No slogans found')
|
console.log('No slogans found')
|
||||||
}
|
}
|
||||||
|
|
||||||
// Split the slogan into array
|
// Split the slogan into array
|
||||||
const sloganArray = sloganText.split(' ')
|
var sloganArray = sloganText.split(" ");
|
||||||
const slogan = {
|
var slogan = {
|
||||||
white: '',
|
white: '',
|
||||||
blue: ''
|
blue: ''
|
||||||
}
|
};
|
||||||
|
|
||||||
// Set the last word in the array to be blue
|
// Set the last word in the array to be blue
|
||||||
if (sloganArray.length > 1) {
|
if (sloganArray.length > 1) {
|
||||||
slogan.blue = sloganArray.pop()
|
slogan.blue = sloganArray.pop();
|
||||||
for (let index = 0; index < sloganArray.length; index++) {
|
for (let index = 0; index < sloganArray.length; index++) {
|
||||||
slogan.white = slogan.white + sloganArray[index] + ' '
|
slogan.white = slogan.white + sloganArray[index] + " ";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
slogan.white = sloganArray
|
slogan.white = sloganArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Edit HTML
|
// Edit HTML
|
||||||
document.getElementById('slogan').innerHTML =
|
document.getElementById('slogan').innerHTML =
|
||||||
`<span class="white block">${slogan.white}</span><span>${slogan.blue}</span>`
|
`<span class="white block">${slogan.white}</span>
|
||||||
|
<span>${slogan.blue}</span>`
|
||||||
|
;
|
||||||
|
|
||||||
// Add a little credit
|
// 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
|
// Send request to background script
|
||||||
browser.runtime.sendMessage({
|
browser.runtime.sendMessage({ type: "get"});
|
||||||
type: 'get'
|
|
||||||
})
|
|
||||||
|
|
||||||
// Receive response from background script
|
// Receive response from background script
|
||||||
browser.runtime.onMessage.addListener(changeSlogan)
|
browser.runtime.onMessage.addListener(changeSlogan);
|
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
"name": "SOMtodayn't",
|
"name": "SOMtodayn't",
|
||||||
"version": "1.22.0",
|
"version": "1.15",
|
||||||
"author": "Arne van Iterson",
|
"author": "McArn",
|
||||||
|
|
||||||
"description": "Changes the slogan on the login page of the school management system SOMtoday.",
|
"description": "Changes the slogan on the login page of the school management system SOMtoday.",
|
||||||
|
|
||||||
@ -13,11 +13,6 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
"permissions": [
|
|
||||||
"tabs",
|
|
||||||
"storage"
|
|
||||||
],
|
|
||||||
|
|
||||||
"icons": {
|
"icons": {
|
||||||
"25" : "assets/icons/25.png",
|
"25" : "assets/icons/25.png",
|
||||||
"32" : "assets/icons/32.png",
|
"32" : "assets/icons/32.png",
|
||||||
@ -26,10 +21,7 @@
|
|||||||
|
|
||||||
"background": {
|
"background": {
|
||||||
"persistent": true,
|
"persistent": true,
|
||||||
"scripts": [
|
"scripts": ["background/js/index.js"]
|
||||||
"vendor/browser-polyfill.js",
|
|
||||||
"background/js/index.js"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
|
|
||||||
"browser_action": {
|
"browser_action": {
|
||||||
@ -41,17 +33,10 @@
|
|||||||
"default_popup": "popup/html/index.html"
|
"default_popup": "popup/html/index.html"
|
||||||
},
|
},
|
||||||
|
|
||||||
"web_accessible_resources": [
|
|
||||||
"content/css/index.css"
|
|
||||||
],
|
|
||||||
|
|
||||||
"content_scripts": [
|
"content_scripts": [
|
||||||
{
|
{
|
||||||
"matches": ["*://*.somtoday.nl/*"],
|
"matches": ["*://*.somtoday.nl/*"],
|
||||||
"js": [
|
"js": ["content/js/index.js"]
|
||||||
"vendor/browser-polyfill.js",
|
|
||||||
"content/js/index.js"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
5774
package-lock.json
generated
5774
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
26
package.json
26
package.json
@ -1,26 +0,0 @@
|
|||||||
{
|
|
||||||
"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,7 +2,6 @@
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<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 href="https://fonts.googleapis.com/css?family=Bree+Serif&display=swap" rel="stylesheet">
|
||||||
<link rel="stylesheet" href="../css/index.css">
|
<link rel="stylesheet" href="../css/index.css">
|
||||||
</head>
|
</head>
|
||||||
@ -10,24 +9,16 @@
|
|||||||
<div>
|
<div>
|
||||||
<h2>SOMtodayn't</h2>
|
<h2>SOMtodayn't</h2>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h3>Slogan toevoegen</h3>
|
<h3>Slogan toevoegen</h3>
|
||||||
<h6>Het laatste woord van de slogan wordt blauw.</h6>
|
<h6>Het laatste woord van de slogan wordt blauw.</h6>
|
||||||
<form id="sloganForm">
|
<form id="sloganForm">
|
||||||
<input type="text" placeholder="Nieuwe slogan">
|
<input type="text" placeholder="Nieuwe slogan">
|
||||||
<button type="submit">Toevoegen</button>
|
<button type="submit">Toevoegen</button>
|
||||||
</form>
|
</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>
|
<h3>Bestaande slogans</h3>
|
||||||
<h6>Klik op een slogan om deze te verwijderen.</h6>
|
<h6>Klik op een slogan om deze te verwijderen.</h6>
|
||||||
<div id="sloganList">
|
<div id="sloganList">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<span class="footer">By McArn - 2019</span>
|
<span class="footer">By McArn - 2019</span>
|
||||||
<script src="../js/index.js"></script>
|
<script src="../js/index.js"></script>
|
||||||
</body>
|
</body>
|
||||||
|
@ -1,103 +1,75 @@
|
|||||||
console.log("SOMtodayn't popup loaded.")
|
console.log("SOMtodayn't popup loaded.");
|
||||||
let request
|
var request;
|
||||||
|
var response;
|
||||||
|
|
||||||
// Get slogans from background script
|
// Get slogans from background script
|
||||||
request = browser.runtime.sendMessage({
|
request = browser.runtime.sendMessage({
|
||||||
type: 'get'
|
type: "get"
|
||||||
})
|
});
|
||||||
request.then(function (message) {
|
request.then(function(message) {
|
||||||
const darkmode = message.response[0]
|
var sloganArray = message.response;
|
||||||
const sloganArray = message.response[1]
|
// DEBUG // console.log(message.response);
|
||||||
|
|
||||||
// Add a slogan to the array
|
// Add a slogan to the array
|
||||||
function addSlogan (value) {
|
function addSlogan(value) {
|
||||||
sloganArray.push(value)
|
sloganArray.push(value);
|
||||||
updateSlogans(sloganArray)
|
updateSlogans(sloganArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove a slogan from the array
|
// Remove a slogan from the array
|
||||||
function removeSlogan (id) {
|
function removeSlogan(id) {
|
||||||
const array = []
|
var array = [];
|
||||||
if (sloganArray.length > 1) {
|
if (sloganArray.length > 1) {
|
||||||
for (let index = 0; index < sloganArray.length; index++) {
|
for (let index = 0; index < sloganArray.length; index++) {
|
||||||
const element = sloganArray[index]
|
const element = sloganArray[index];
|
||||||
if (index !== id) {
|
if (index != id) {
|
||||||
array.push(element)
|
array.push(element);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
updateSlogans(array);
|
||||||
|
} else {
|
||||||
|
window.alert("U kunt de laatste slogan niet verwijderen.");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
updateSlogans(array)
|
|
||||||
} else {
|
|
||||||
window.alert('U kunt de laatste slogan niet verwijderen.')
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Send updated array to background script
|
// Send updated array to background script
|
||||||
function updateSlogans (array) {
|
function updateSlogans(array) {
|
||||||
request = browser.runtime.sendMessage({
|
request = browser.runtime.sendMessage({
|
||||||
type: 'setSlogans',
|
type: "set",
|
||||||
value: array
|
value: array
|
||||||
})
|
});
|
||||||
request.then(function () {
|
request.then(function() {
|
||||||
location.reload()
|
location.reload();
|
||||||
}, handleError)
|
}, 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')
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Handle query errors
|
// Add existing slogans to list items in the popup
|
||||||
function onError (error) {
|
var sloganList = '';
|
||||||
console.log(`Error: ${error}`)
|
for (let index = 0; index < sloganArray.length; index++) {
|
||||||
}
|
const element = sloganArray[index];
|
||||||
|
sloganList = sloganList + `<ul>${element}</ul>`;
|
||||||
|
}
|
||||||
|
document.getElementById('sloganList').innerHTML = sloganList;
|
||||||
|
|
||||||
// Add existing slogans to list items in the popup
|
// Get value for new slogan
|
||||||
let sloganList = ''
|
document.getElementById('sloganForm').addEventListener('submit', function(event) {
|
||||||
for (let index = 0; index < sloganArray.length; index++) {
|
event.preventDefault();
|
||||||
const element = sloganArray[index]
|
addSlogan(event.target.children[0].value);
|
||||||
sloganList = sloganList + `<ul>${element}</ul>`
|
event.target.children[0].value = '';
|
||||||
}
|
});
|
||||||
document.getElementById('sloganList').innerHTML = sloganList
|
|
||||||
|
|
||||||
// Get value for new slogan
|
// Add event listener to every list item for deleting slogans
|
||||||
document.getElementById('sloganForm').addEventListener('submit', function (event) {
|
var listElements = document.querySelectorAll("div#sloganList > ul");
|
||||||
event.preventDefault()
|
for (let index = 0; index < listElements.length; index++) {
|
||||||
addSlogan(event.target.children[0].value)
|
const element = listElements[index];
|
||||||
event.target.children[0].value = ''
|
element.addEventListener("click", function() {
|
||||||
})
|
removeSlogan(index);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Add event listener to every list item for deleting slogans
|
}, handleError);
|
||||||
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) {
|
function handleError(error) {
|
||||||
console.error(`SOMtodayn't Error: ${error}`)
|
console.error(`SOMtodayn't Error: ${error}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
1187
vendor/browser-polyfill.js
vendored
1187
vendor/browser-polyfill.js
vendored
File diff suppressed because it is too large
Load Diff
1
vendor/browser-polyfill.js.map
vendored
1
vendor/browser-polyfill.js.map
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user