Compare commits
No commits in common. "f4b87628ea86c13c2a780400a30a6a851fcfebf0" and "faeffc41e6c6af8c5c850d5db8d81f1b8143b8a5" have entirely different histories.
f4b87628ea
...
faeffc41e6
@ -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
|
||||
}
|
||||
}
|
@ -1,63 +1,59 @@
|
||||
console.log('SOMtodayn\'t background script loaded')
|
||||
|
||||
// Read array from local storage
|
||||
function getSlogans () {
|
||||
let slogans
|
||||
let tonight
|
||||
|
||||
function getSlogans() {
|
||||
var slogans;
|
||||
if (localStorage.getItem('SOMtodayntSlogans') != null) {
|
||||
slogans = JSON.parse(localStorage.getItem('SOMtodayntSlogans'))
|
||||
tonight = JSON.parse(localStorage.getItem('SOMtonight'))
|
||||
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))
|
||||
var slogans = [ "Welkom bij SOMtodayn't" ];
|
||||
var 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))
|
||||
function setTonight(value) {
|
||||
localStorage.setItem('SOMtonight', JSON.stringify(value));
|
||||
return;
|
||||
}
|
||||
|
||||
// Handle requests
|
||||
function handleMessage (request, sender, sendResponse) {
|
||||
let response
|
||||
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
|
||||
response = getSlogans();
|
||||
break;
|
||||
|
||||
case 'setSlogans':
|
||||
response = setSlogans(request.value)
|
||||
break
|
||||
response = setSlogans(request.value);
|
||||
break;
|
||||
|
||||
case 'setTonight':
|
||||
response = setTonight(request.value)
|
||||
break
|
||||
response = setTonight(request.value);
|
||||
break;
|
||||
}
|
||||
// Send response to either the content script or popup
|
||||
if (sender.tab) {
|
||||
browser.tabs.sendMessage(sender.tab.id, response)
|
||||
browser.tabs.sendMessage(sender.tab.id, response);
|
||||
} else {
|
||||
sendResponse({
|
||||
response: response
|
||||
})
|
||||
sendResponse({response: response});
|
||||
}
|
||||
// DEBUG // console.log("Response: " + response)
|
||||
}
|
||||
|
||||
browser.runtime.onMessage.addListener(handleMessage)
|
||||
browser.runtime.onMessage.addListener(handleMessage);
|
@ -2,9 +2,6 @@
|
||||
body {
|
||||
background-color: #121212;
|
||||
}
|
||||
a {
|
||||
color: #01a299;
|
||||
}
|
||||
|
||||
/* Login screen */
|
||||
/* Background */
|
||||
@ -203,32 +200,6 @@ div#detail-panel-wrapper {
|
||||
.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;
|
||||
|
@ -1,63 +1,62 @@
|
||||
console.log('Somtoday\'nt content script active')
|
||||
console.log('Somtoday\'nt content script active');
|
||||
|
||||
function changeSlogan (message) {
|
||||
if (message === 'reload') {
|
||||
location.reload()
|
||||
function changeSlogan(message)
|
||||
{
|
||||
if (message == 'reload') {
|
||||
location.reload();
|
||||
} else {
|
||||
const tonight = message[0]
|
||||
const slogans = message[1]
|
||||
tonight = message[0];
|
||||
slogans = message[1];
|
||||
|
||||
// Set theme
|
||||
console.log(tonight)
|
||||
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
|
||||
var cssUrl = browser.runtime.getURL("content/css/index.css");
|
||||
var cssTag = `<link rel='stylesheet' href='${cssUrl}'>`;
|
||||
document.head.innerHTML += cssTag;
|
||||
}
|
||||
|
||||
// Select random slogan
|
||||
console.log(`Loaded ${slogans.length} slogans`)
|
||||
let sloganText
|
||||
|
||||
console.log(`Loaded ${slogans.length} slogans`);
|
||||
if (slogans.length >= 1) {
|
||||
const random = Math.floor(Math.random() * slogans.length)
|
||||
sloganText = slogans[random].toLowerCase()
|
||||
console.log(`Slogan changed to: ${sloganText}`)
|
||||
var random = Math.floor(Math.random() * slogans.length);
|
||||
var sloganText = slogans[random].toLowerCase();
|
||||
console.log(`Slogan changed to: ${sloganText}`);
|
||||
} else {
|
||||
sloganText = "welkom bij somtodayn't"
|
||||
var sloganText = "welkom bij somtodayn't";
|
||||
console.log('No slogans found')
|
||||
}
|
||||
|
||||
// Split the slogan into array
|
||||
const sloganArray = sloganText.split(' ')
|
||||
const slogan = {
|
||||
var sloganArray = sloganText.split(" ");
|
||||
var slogan = {
|
||||
white: '',
|
||||
blue: ''
|
||||
}
|
||||
};
|
||||
|
||||
// Set the last word in the array to be blue
|
||||
if (sloganArray.length > 1) {
|
||||
slogan.blue = sloganArray.pop()
|
||||
slogan.blue = sloganArray.pop();
|
||||
for (let index = 0; index < sloganArray.length; index++) {
|
||||
slogan.white = slogan.white + sloganArray[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>`
|
||||
`<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.22.0",
|
||||
"author": "Arne van Iterson",
|
||||
"version": "1.20",
|
||||
"author": "McArn",
|
||||
|
||||
"description": "Changes the slogan on the login page of the school management system SOMtoday.",
|
||||
|
||||
|
5784
package-lock.json
generated
5784
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"
|
||||
}
|
@ -1,103 +1,106 @@
|
||||
console.log("SOMtodayn't popup loaded.")
|
||||
let request
|
||||
console.log("SOMtodayn't popup loaded.");
|
||||
var request;
|
||||
var response;
|
||||
|
||||
// Get slogans from background script
|
||||
request = browser.runtime.sendMessage({
|
||||
type: 'get'
|
||||
})
|
||||
request.then(function (message) {
|
||||
const darkmode = message.response[0]
|
||||
const sloganArray = message.response[1]
|
||||
type: "get"
|
||||
});
|
||||
request.then(function(message) {
|
||||
var darkmode = message.response[0];
|
||||
var sloganArray = message.response[1];
|
||||
|
||||
// Add a slogan to the array
|
||||
function addSlogan (value) {
|
||||
sloganArray.push(value)
|
||||
updateSlogans(sloganArray)
|
||||
function addSlogan(value) {
|
||||
sloganArray.push(value);
|
||||
updateSlogans(sloganArray);
|
||||
}
|
||||
|
||||
// Remove a slogan from the array
|
||||
function removeSlogan (id) {
|
||||
const 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)
|
||||
const element = sloganArray[index];
|
||||
if (index != id) {
|
||||
array.push(element);
|
||||
}
|
||||
}
|
||||
updateSlogans(array)
|
||||
updateSlogans(array);
|
||||
} else {
|
||||
window.alert('U kunt de laatste slogan niet verwijderen.')
|
||||
window.alert("U kunt de laatste slogan niet verwijderen.");
|
||||
}
|
||||
}
|
||||
|
||||
// Send updated array to background script
|
||||
function updateSlogans (array) {
|
||||
function updateSlogans(array) {
|
||||
request = browser.runtime.sendMessage({
|
||||
type: 'setSlogans',
|
||||
type: "setSlogans",
|
||||
value: array
|
||||
})
|
||||
request.then(function () {
|
||||
location.reload()
|
||||
}, handleError)
|
||||
});
|
||||
request.then(function() {
|
||||
location.reload();
|
||||
}, handleError);
|
||||
}
|
||||
|
||||
// Add event listener to checkbox
|
||||
const checkbox = document.getElementById('tonight')
|
||||
var checkbox = document.getElementById('tonight');
|
||||
if (darkmode) {
|
||||
checkbox.checked = true
|
||||
checkbox.checked = true;
|
||||
}
|
||||
checkbox.addEventListener('click', function (event) {
|
||||
checkbox.addEventListener('click', function(event) {
|
||||
// Update value in local storage
|
||||
request = browser.runtime.sendMessage({
|
||||
type: 'setTonight',
|
||||
type: "setTonight",
|
||||
value: checkbox.checked
|
||||
})
|
||||
});
|
||||
// Reload all SOMtoday tabs
|
||||
const reload = browser.tabs.query({})
|
||||
reload.then(logTabs, onError)
|
||||
})
|
||||
var reload = browser.tabs.query({});
|
||||
reload.then(logTabs, onError);
|
||||
});
|
||||
|
||||
// Find id of somtoday.nl tab
|
||||
function logTabs (tabs) {
|
||||
for (const tab of tabs) {
|
||||
function logTabs(tabs) {
|
||||
for (let tab of tabs) {
|
||||
// Match only tabs with url somtoday.nl
|
||||
if (tab.url.includes('somtoday.nl')) {
|
||||
browser.tabs.sendMessage(tab.id, 'reload')
|
||||
browser.tabs.sendMessage(tab.id, 'reload');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Handle query errors
|
||||
function onError (error) {
|
||||
console.log(`Error: ${error}`)
|
||||
function onError(error) {
|
||||
console.log(`Error: ${error}`);
|
||||
}
|
||||
|
||||
// Add existing slogans to list items in the popup
|
||||
let sloganList = ''
|
||||
var sloganList = '';
|
||||
for (let index = 0; index < sloganArray.length; index++) {
|
||||
const element = sloganArray[index]
|
||||
sloganList = sloganList + `<ul>${element}</ul>`
|
||||
const element = sloganArray[index];
|
||||
sloganList = sloganList + `<ul>${element}</ul>`;
|
||||
}
|
||||
document.getElementById('sloganList').innerHTML = sloganList
|
||||
document.getElementById('sloganList').innerHTML = sloganList;
|
||||
|
||||
// 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 = ''
|
||||
})
|
||||
document.getElementById('sloganForm').addEventListener('submit', function(event) {
|
||||
event.preventDefault();
|
||||
addSlogan(event.target.children[0].value);
|
||||
event.target.children[0].value = '';
|
||||
});
|
||||
|
||||
// Add event listener to every list item for deleting slogans
|
||||
const listElements = document.querySelectorAll('div#sloganList > ul')
|
||||
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)
|
||||
})
|
||||
const element = listElements[index];
|
||||
element.addEventListener("click", function() {
|
||||
removeSlogan(index);
|
||||
});
|
||||
}
|
||||
}, handleError)
|
||||
|
||||
function handleError (error) {
|
||||
console.error(`SOMtodayn't Error: ${error}`)
|
||||
}, handleError);
|
||||
|
||||
function handleError(error) {
|
||||
console.error(`SOMtodayn't Error: ${error}`);
|
||||
}
|
||||
|
||||
|
1256
vendor/browser-polyfill.js
vendored
1256
vendor/browser-polyfill.js
vendored
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user