JSFiddle - React, Tailwind, and code Playground
JavaScript
// ==UserScript==
// @name DeGiro Kernselectie
// @namespace http://tampermonkey.net/
// @version 0.1
// @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':
highlightKernselectieForFavouritesPage();
break;
case 'INSTRUMENT_PAGE':
highlightKernselectieForInstrumentPage();
break;
case 'UNKNOWN':
default:
console.log(`Unable to determine page type for ${window.location.hash}`);
break;
}
};
function highlightKernselectieForFavouritesPage() {
document.querySelectorAll('.favourites__table tbody tr').forEach((el)=>{
let isin = el.querySelector('[data-field=isin]').textContent;
if(isKernSelectie(isin)) {
el.querySelector('[data-field=isin]').parentElement.style.color = deGiroBlue;
el.querySelector('[data-field=isin]').parentElement.title = kernSelectieTitle;
}
});
};
function highlightKernselectieForInstrumentPage() {
let el = document.querySelectorAll('.product-details_buysell table tr')[1].querySelectorAll('td')[1];
let isin = el.textContent;
if(isKernSelectie(isin)) {
el.style.color = deGiroBlue;
el.title = kernSelectieTitle;
} else {
el.style.color = null;
el.title = null;
};
};
function determinePageType() {
if (window.location.hash === '#/favourites') {
return...