Created
May 9, 2024 06:16
-
-
Save jxpsert/84d098d4003aff09ae5d6c0c05171321 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name MeldingSelector | |
| // @namespace http://tampermonkey.net/ | |
| // @version 2024-05-09 | |
| // @description Meldingen kunnen openen in een nieuw tabblad | |
| // @author Jasper Platenburg | |
| // @match https://nijmegen.jouw-omgeving.nl/* | |
| // @icon https://www.google.com/s2/favicons?sz=64&domain=jouw-omgeving.nl | |
| // @grant none | |
| // ==/UserScript== | |
| (function() { | |
| 'use strict'; | |
| setTimeout(() => { | |
| const filterBtn = document.querySelector('.filterbutton'); | |
| const newBtn = filterBtn.cloneNode(true); | |
| newBtn.querySelector('button').innerText = "Links"; | |
| filterBtn.parentElement.append(newBtn); | |
| newBtn.addEventListener('click', btnClick); | |
| }, 2000); | |
| const btnClick = () => { | |
| setRows(getRows()); | |
| } | |
| const setRows = (rows) => { | |
| rows.forEach(row => { | |
| console.log('Found row!'); | |
| const cells = row.querySelectorAll('td'); | |
| const id = cells[0].innerText; | |
| cells.forEach(cell => { cell.removeAttribute("onclick"); cell.removeAttribute("style") }); | |
| console.log('Removed click events'); | |
| cells[0].innerHTML = `<a target="_blank" class="btn btn-primary btn-sm" href="/reports/view/${id}">${id}</a>`; | |
| console.log('Placed link'); | |
| }); | |
| }; | |
| const getRows = () => { | |
| const rows = document.querySelectorAll('table.table > tbody > tr'); | |
| return rows; | |
| }; | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment