Last active
July 18, 2025 14:15
-
-
Save jkremser/d925b031a516e66fa2e1771252ade21f to your computer and use it in GitHub Desktop.
freshbox
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 to ical (fresh) | |
| // @namespace http://tampermonkey.net/ | |
| // @version 2025-07-17 | |
| // @description Make ical | |
| // @author jkremser | |
| // @match https://www.freshbox.cz/muj/vyber/* | |
| // @icon https://www.freshbox.cz/apple-touch-icon.png | |
| // @require https://raw.githubusercontent.com/matthiasanderer/icsFormatter/refs/heads/master/icsFormatter.js | |
| // @grant none | |
| // ==/UserScript== | |
| (async function() { | |
| //'use strict'; | |
| //const { createEvent } = await import("https://cdn.jsdelivr.net/npm/ics@3.8.1/+esm"); | |
| //const { createEvent } = await import("https://esm.run/ics") ; | |
| var calEntry = icsFormatter(); | |
| const daysDiv = document.querySelector("div.container-xxl > div.row > div"); | |
| let datum = new Date(); | |
| for (var j = 0; j < daysDiv.children.length; j++) { | |
| let jidlo = ''; | |
| const row = daysDiv.children[j]; | |
| if (j % 2 == 0) { | |
| // Pondělí - 14.07.2025 | |
| const date = row.innerText; | |
| const chunks = date.split('-')[1].split('.'); | |
| const year = chunks[2]; | |
| const month = chunks[1]; | |
| const day = chunks[0]; | |
| datum = new Date(Date.parse(`${year}-${month}-${day}`)); | |
| console.log(datum); | |
| } else { | |
| for (var k = 1; k < row.children.length; k++) { | |
| if (row.children[k].tagName != 'DIV') { | |
| continue; | |
| } | |
| let newJidlo = row.children[k].children[1].innerText.normalize("NFD").replace(/[\u0300-\u036f]/g, ""); | |
| newJidlo = newJidlo.replace(/.* kJ\s/g, '').replace(/\s\|.*/g, ''); | |
| //console.log(newJidlo); | |
| if (!jidlo.includes(newJidlo)) { | |
| //if (jidlo == "") { | |
| jidlo += newJidlo + ' '; | |
| } | |
| } | |
| var place = 'doma'; | |
| var end = new Date(datum.getTime() + 45*60000); | |
| calEntry.addEvent(jidlo, '', place, datum.toUTCString(), end.toUTCString()); | |
| } | |
| } | |
| //calEntry.download('jidelnicek.ics'); | |
| console.log(calEntry.calendar()); | |
| const foo = document.createElement('a'); | |
| foo.class= 'nav-link'; | |
| foo.href = 'data:application/octet-stream;charset=utf-16le;base64,' + btoa(calEntry.calendar()); | |
| foo.download = 'jidelnicek.ics'; | |
| foo.innerHTML='jidelnicek.ics'; | |
| const parent = document.getElementById('secondNav'); | |
| parent.appendChild(foo); | |
| //anchor.click(); | |
| //document.body.removeChild(anchor); | |
| //URL.revokeObjectURL(url); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment