2024-09-06 14:13:10 +02:00
|
|
|
// ==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 = {
|
2024-09-06 14:18:20 +02:00
|
|
|
sport: "#186f37"
|
2024-09-06 14:13:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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!")
|
|
|
|
})
|