feat: iltapulu catalog sports events highlighter
This commit is contained in:
parent
eb4b4dfe9c
commit
a33a617e7b
54
iltapulu.fi/ip-highlight.js
Normal file
54
iltapulu.fi/ip-highlight.js
Normal file
@ -0,0 +1,54 @@
|
||||
// ==UserScript==
|
||||
// @name ip-highlight
|
||||
// @description TV catalog item highlighter
|
||||
// @author ae
|
||||
// @namespace Violentmonkey Scripts
|
||||
// @match *://www.iltapulu.fi/
|
||||
// @version 1.0
|
||||
// ==/UserScript==
|
||||
|
||||
const channelTags = [
|
||||
"#channel-1", // YLE 1
|
||||
"#channel-2", // YLE 2
|
||||
"#channel-3", // MTV3
|
||||
"#channel-4", // 4
|
||||
"#channel-6", // MTV Sub
|
||||
"#channel-5", // TV5
|
||||
"#channel-62" // 6
|
||||
]
|
||||
|
||||
const highlightCodes = {
|
||||
sport: "#1c9346"
|
||||
}
|
||||
|
||||
const findSportsItems = () => {
|
||||
let rawItems = []
|
||||
|
||||
channelTags.forEach((tag) => {
|
||||
const query = `${tag} .op`
|
||||
const channelItems = document.querySelectorAll(query)
|
||||
rawItems.push(...channelItems)
|
||||
})
|
||||
|
||||
let sportsItems = []
|
||||
|
||||
rawItems.forEach((item) => {
|
||||
const afterStyle = window.getComputedStyle(item, "::after")
|
||||
|
||||
if (afterStyle.content !== "none" && afterStyle.content !== '""') {
|
||||
sportsItems.push(item)
|
||||
}
|
||||
})
|
||||
|
||||
return sportsItems
|
||||
}
|
||||
|
||||
window.addEventListener("load", () => {
|
||||
const sportsItems = findSportsItems()
|
||||
|
||||
sportsItems.forEach((item) => {
|
||||
item.parentElement.style.backgroundColor = highlightCodes["sport"]
|
||||
})
|
||||
|
||||
console.log("ip-highlight.js: All sports events highlighted successfully!")
|
||||
})
|
Loading…
Reference in New Issue
Block a user