Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name DresdenBacklight
- // @namespace Violentmonkey Scripts
- // @grant none
- // ==/UserScript==
- const whiteColor = '#ffffff'
- function findPlace() {
- let currentPlace = document.getElementsByName('freeTimeContainer:free_time.place')[0];
- if (typeof(currentPlace) !== 'undefined') {
- currentPlace = currentPlace.selectedIndex;
- for (let obj in arrayForPlaces) {
- if (currentPlace === arrayForPlaces[obj].idPlace) {
- backlighting(arrayForPlaces[obj].timeTOPlay, arrayForPlaces[obj].color);
- }
- }
- }
- }
- function backlighting(userWord, color) {
- let word = userWord;
- let queue = [document.body];
- let curr;
- while (curr = queue.pop()) {
- if (!curr.textContent.match(word)) continue;
- for (let i = 0; i < curr.childNodes.length; ++i) {
- switch (curr.childNodes[i].nodeType) {
- case Node.TEXT_NODE : // 3
- if (curr.childNodes[i].textContent.match(word)) {
- console.log("Found!");
- console.log(curr);
- curr.style.background = color;
- }
- break;
- case Node.ELEMENT_NODE : // 1
- queue.push(curr.childNodes[i]);
- break;
- }
- }
- }
- }
- let arrayForPlaces = [{
- idPlace: 14,
- timeTOPlay: '19:30 - 20:00',
- color: whiteColor
- },
- {
- idPlace: 15,
- timeTOPlay: '20:30 - 21:00',
- color: whiteColor
- },
- {
- idPlace: 16,
- timeTOPlay: '21:30 - 22:00',
- color: whiteColor
- }, {
- idPlace: 28,
- timeTOPlay: '18:30 - 19:00',
- color: whiteColor
- }];
- findPlace();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement