JSFiddle - React, Tailwind, and code Playground
JavaScript
// ==UserScript==
// @name DeGiro Kernselectie
// @namespace http://tampermonkey.net/
// @version 0.5
// @description Show whether the ISIN is in the kernselectie
// @match https://trader.degiro.nl/*
// @grant none
// @run-at document-end
// ==/UserScript==
(function() {
'use strict';
//Re-check the page whenever the url changes
window.onhashchange = function() {
setTimeout(highlightKernselectie, 1000);
}
function highlightKernselectie() {
let pageType = determinePageType();
switch (pageType) {
case 'FAVOURITES':
highlightKernselectieForTable('.favourites__table tbody tr');
break;
case 'INSTRUMENT_PAGE':
highlightKernselectieForInstrumentPage();
break;
case 'INSTRUMENT_SEARCH':
highlightKernselectieForTable('.prices__table tbody tr');
break;
case 'UNKNOWN':
default:
console.log(`Unable to determine page type for ${window.location.hash}`);
break;
}
};
function highlightKernselectieForTable(tableRowSelector) {
document.querySelectorAll(tableRowSelector).forEach((el)=>{
let isin = el.querySelector('[data-field=isin]').textContent;
if(isKernSelectie(isin)) {
if(!el.querySelector('span[data-kernselection]')) {
el.querySelector('[data-field=isin]').appendChild(getKernselectieNode());
} else {
//already highlighted'
}
} else {
if(el.querySelector('span[data-kernselection]')) {
el.querySelector('[data-field=isin]').removeChild(el.querySelector('span[data-kernselection]'));
};
};
});
};
function highlightKernselectieForInstrumentPage() {
let el =...