@@ -469,34 +382,9 @@
async function init() {
if (window.location.pathname.includes('/Adminisztracio/Profil')) {
- const links = [
- { rel: 'preconnect', href: 'https://fonts.googleapis.com' },
- { rel: 'preconnect', href: 'https://fonts.gstatic.com', crossorigin: true },
- { rel: 'stylesheet', href: 'https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100..900;1,100..900&display=swap' },
- { rel: 'stylesheet', href: 'https://fonts.googleapis.com/icon?family=Material+Icons+Round' }
- ];
+ createTemplate.importFonts();
- links.forEach(link => {
- const linkElement = document.createElement('link');
- Object.entries(link).forEach(([key, value]) => {
- linkElement[key] = value;
- });
- document.head.appendChild(linkElement);
- });
-
- const userData = {
- schoolInfo: {
- name: getCookie('schoolName') || 'Iskola',
- id: getCookie('schoolCode') || ''
- },
- userData: {
- name: getCookie('userName') || 'Felhasználó',
- time: document.querySelector('.usermenu_timer')?.textContent?.trim() || '45:00',
- email: getCookie('userEmail') || ''
- }
- };
-
- document.body.innerHTML = createProfileHTML(userData);
+ document.body.innerHTML = createProfileHTML();
setupEventListeners();
setupContactForm();
}
diff --git a/roleselect/roleselect.js b/roleselect/roleselect.js
index 17fbe65..02c1f53 100644
--- a/roleselect/roleselect.js
+++ b/roleselect/roleselect.js
@@ -1,11 +1,4 @@
(() => {
-
- const setCookie = (name, value, days = 365) => {
- const date = new Date();
- date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
- document.cookie = `${name}=${value}; expires=${date.toUTCString()}; path=/; domain=.e-kreta.hu`;
- };
-
const startLogoutTimer = () => {
let timeLeft = 45 * 60;
const timerElement = document.getElementById('logoutTimer');
@@ -124,30 +117,18 @@
if (schoolCode && fullSchoolName) {
- setCookie('schoolCode', schoolCode);
- setCookie('schoolName', fullSchoolName);
- setCookie('schoolSubdomain', schoolSubdomain);
+ cookieManager.set('schoolCode', schoolCode);
+ cookieManager.set('schoolName', fullSchoolName);
+ cookieManager.set('schoolSubdomain', schoolSubdomain);
}
if (userName) {
- setCookie('userName', userName);
+ cookieManager.set('userName', userName);
}
document.body.innerHTML = createHTML(schoolCode, fullSchoolName, userName);
-
- const links = [
- { rel: 'preconnect', href: 'https://fonts.googleapis.com' },
- { rel: 'preconnect', href: 'https://fonts.gstatic.com', crossorigin: true },
- { href: 'https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100..900;1,100..900&family=Figtree:wght@300..900&display=swap', rel: 'stylesheet' }
- ];
-
- links.forEach(link => {
- const linkElement = document.createElement('link');
- Object.entries(link).forEach(([key, value]) => linkElement[key] = value);
- document.head.appendChild(linkElement);
- });
-
+ createTemplate.importFonts();
const timerInterval = startLogoutTimer();
diff --git a/timetable/timetable.css b/timetable/timetable.css
index 3094560..372e198 100644
--- a/timetable/timetable.css
+++ b/timetable/timetable.css
@@ -43,57 +43,6 @@ body {
font-size: 16px;
}
-/* Loading Screen */
-.loading-screen {
- position: fixed;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- background-color: var(--background);
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- z-index: 9999;
-}
-
-.loading-logo {
- width: 48px;
- height: 48px;
- border-radius: 16px;
-}
-
-.loading-text {
- color: var(--text-primary);
- text-align: center;
- font-family: Montserrat;
- font-size: 20px;
- font-style: normal;
- font-weight: 700;
- line-height: normal;
-}
-
-.loading-text2 {
- align-self: stretch;
- color: var(--text-secondary);
- text-align: center;
- font-family: Figtree;
- font-size: 16px;
- font-style: normal;
- font-weight: 500;
- line-height: 130%;
-}
-
-@keyframes spin {
- from {
- transform: rotate(0deg);
- }
- to {
- transform: rotate(360deg);
- }
-}
-
@media (max-width: 768px) {
body {
font-size: 14px;
diff --git a/timetable/timetable.js b/timetable/timetable.js
index febd155..f012e09 100644
--- a/timetable/timetable.js
+++ b/timetable/timetable.js
@@ -1,85 +1,8 @@
(() => {
- // Segédfüggvények
- function convertTimeToMinutes(timeStr) {
- const [hours, minutes] = timeStr.split(':').map(Number);
- return hours * 60 + minutes;
- }
- function getCookie(name) {
- const cookieName = `${name}=`;
- const decodedCookie = decodeURIComponent(document.cookie);
- const cookieArray = decodedCookie.split(';');
-
- for(let i = 0; i < cookieArray.length; i++) {
- let cookie = cookieArray[i];
- while (cookie.charAt(0) === ' ') {
- cookie = cookie.substring(1);
- }
- if (cookie.indexOf(cookieName) === 0) {
- return cookie.substring(cookieName.length, cookie.length);
- }
- }
- return null;
- }
-
- function shortenSchoolName(name, maxLength = 50) {
- if (!name) return '';
- if (name.length <= maxLength) return name;
-
- const parts = name.split(' - ');
- if (parts.length === 2) {
- const [code, fullName] = parts;
- if (fullName.length > maxLength - code.length - 3) {
- return `${code} - ${fullName.substring(0, maxLength - code.length - 6)}...`;
- }
- }
- return name.substring(0, maxLength - 3) + '...';
- }
-
- function showLoadingScreen() {
- const loadingScreen = document.createElement('div');
- loadingScreen.className = 'loading-screen';
- loadingScreen.innerHTML = `
-

-
Betöltés alatt...
-
Kis türelmet!
- `;
- document.body.appendChild(loadingScreen);
- }
-
- function hideLoadingScreen() {
- const loadingScreen = document.querySelector('.loading-screen');
- if (loadingScreen) {
- loadingScreen.style.opacity = '0';
- loadingScreen.style.transition = 'opacity 0.3s ease';
- setTimeout(() => loadingScreen.remove(), 300);
- }
- }
-
- // DOM elemek várása
- function waitForElement(selector) {
- return new Promise(resolve => {
- if (document.querySelector(selector)) {
- return resolve(document.querySelector(selector));
- }
-
- const observer = new MutationObserver(mutations => {
- if (document.querySelector(selector)) {
- observer.disconnect();
- resolve(document.querySelector(selector));
- }
- });
-
- observer.observe(document.body, {
- childList: true,
- subtree: true
- });
- });
- }
-
// Órarendi adatok gyűjtése
async function collectTimetableData() {
- await waitForElement('#Calendar');
- await new Promise(resolve => setTimeout(resolve, 1000));
+ await helper.waitForElement('#Calendar');
+ await helper.waitForElement('.modalBckgroundMain:not(.isOverlayActiv)');
const calendar = document.querySelector('#Calendar');
const dates = Array.from(document.querySelectorAll('.fc-day-header')).map(header => {
@@ -121,11 +44,11 @@
}
const timetableData = {
schoolInfo: {
- name: getCookie('schoolName') || 'Iskola',
- id: getCookie('schoolCode') || ''
+ name: cookieManager.get('schoolName') || 'Iskola',
+ id: cookieManager.get('schoolCode') || ''
},
userData: {
- name: getCookie('userName') || 'Felhasználó',
+ name: cookieManager.get('userName') || 'Felhasználó',
time: document.querySelector('.usermenu_timer')?.textContent?.trim() || '45:00'
},
weekInfo: {
@@ -154,7 +77,7 @@
let originalTeacher = '';
if (teacher.startsWith('Helyettesítő:')) {
event.click();
- originalTeacher = await waitForElement("#OraAdatokDetailTabStrip-1 > div > div:nth-child(3) > div:nth-child(2)");
+ originalTeacher = await helper.waitForElement("#OraAdatokDetailTabStrip-1 > div > div:nth-child(3) > div:nth-child(2)");
originalTeacher = originalTeacher.innerText;
document.querySelector("body > div.k-widget.k-window > div.k-window-titlebar.k-header > div > a:nth-child(2)").click();
}
@@ -181,8 +104,8 @@
// Grid generálása
function generateTimeGrid(lessons, weekDates) {
const times = [...new Set(lessons.map(l => l.startTime))].sort((a, b) => {
- const timeA = convertTimeToMinutes(a);
- const timeB = convertTimeToMinutes(b);
+ const timeA = helper.convertTimeToMinutes(a);
+ const timeB = helper.convertTimeToMinutes(b);
return timeA - timeB;
});
const days = ['Hétfő', 'Kedd', 'Szerda', 'Csütörtök', 'Péntek'];
@@ -361,7 +284,7 @@
const weekSelect = document.querySelector('.week-select');
prevBtn?.addEventListener('click', async () => {
- showLoadingScreen();
+ loadingScreen.show();
const kendoCalendar = document.querySelector('#Calendar')?.__kendoWidget;
if (kendoCalendar) {
kendoCalendar.prev();
@@ -371,7 +294,7 @@
});
nextBtn?.addEventListener('click', async () => {
- showLoadingScreen();
+ loadingScreen.show();
const kendoCalendar = document.querySelector('#Calendar')?.__kendoWidget;
if (kendoCalendar) {
kendoCalendar.next();
@@ -381,7 +304,6 @@
});
weekSelect?.addEventListener('change', async function() {
- showLoadingScreen();
const kendoCombo = document.querySelector('#Calendar_tanevHetek')?.__kendoWidget;
if (kendoCombo) {
kendoCombo.value(this.value);
@@ -390,105 +312,23 @@
await transformTimetablePage();
}
});
-
- // Kijelentkezés időzítő
- const startTime = parseInt(data.userData.time?.match(/\d+/)?.[0] || "45");
- let timeLeft = startTime * 60;
-
- const updateTimer = () => {
- const minutes = Math.floor(timeLeft / 60);
- const seconds = timeLeft % 60;
- const timerEl = document.getElementById('logoutTimer');
- if (timerEl) {
- timerEl.textContent = `${minutes}:${seconds.toString().padStart(2, '0')}`;
- }
-
- if (timeLeft <= 0) {
- window.location.href = '/Home/Logout';
- } else {
- timeLeft--;
- }
- };
-
- updateTimer();
- setInterval(updateTimer, 1000);
}
// Oldal transzformáció
async function transformTimetablePage() {
try {
- showLoadingScreen();
-
const data = await collectTimetableData();
if (!data) {
- hideLoadingScreen();
+ loadingScreen.hide();
return;
}
const schoolNameFull = `${data.schoolInfo.id} - ${data.schoolInfo.name}`;
- const shortenedSchoolName = shortenSchoolName(schoolNameFull);
+ const shortenedSchoolName = helper.shortenSchoolName(schoolNameFull);
document.body.innerHTML = `
-
+ ${createTemplate.header()}
@@ -516,39 +356,17 @@
`;
- // Szükséges fontok hozzáadása
- const links = [
- { rel: 'preconnect', href: 'https://fonts.googleapis.com' },
- { rel: 'preconnect', href: 'https://fonts.gstatic.com', crossorigin: true },
- { rel: 'stylesheet', href: 'https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100..900;1,100..900&display=swap' },
- { rel: 'stylesheet', href: 'https://fonts.googleapis.com/icon?family=Material+Icons+Round' }
- ];
-
- links.forEach(link => {
- const linkElement = document.createElement('link');
- Object.entries(link).forEach(([key, value]) => {
- linkElement[key] = value;
- });
- document.head.appendChild(linkElement);
- });
+ createTemplate.importFonts();
setupEventListeners(data);
- hideLoadingScreen();
+ loadingScreen.hide();
} catch (error) {
console.error('Hiba az oldal átalakítása során:', error);
- hideLoadingScreen();
+ loadingScreen.hide();
}
}
- // Beállítások gomb kezelése
- document.getElementById('settingsBtn')?.addEventListener('click', (e) => {
- e.preventDefault();
- e.stopPropagation();
- const url = chrome.runtime.getURL('settings/index.html');
- window.open(url, '_blank', 'width=400,height=600');
- });
-
if (window.location.href.includes('/Orarend/')) {
transformTimetablePage();
}
diff --git a/tools/cookieManager.js b/tools/cookieManager.js
new file mode 100644
index 0000000..a4a3832
--- /dev/null
+++ b/tools/cookieManager.js
@@ -0,0 +1,25 @@
+const cookieManager = {
+ get(name) {
+ const cookieName = `${name}=`;
+ const decodedCookie = decodeURIComponent(document.cookie);
+ const cookieArray = decodedCookie.split(';');
+
+ for(let i = 0; i < cookieArray.length; i++) {
+ let cookie = cookieArray[i];
+ while (cookie.charAt(0) === ' ') {
+ cookie = cookie.substring(1);
+ }
+ if (cookie.indexOf(cookieName) === 0) {
+ return cookie.substring(cookieName.length, cookie.length);
+ }
+ }
+ return null;
+ },
+
+ set(name, value, days = 365) {
+ const date = new Date();
+ date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
+ const expires = `expires=${date.toUTCString()}`;
+ document.cookie = `${name}=${value}; ${expires}; path=/; domain=.e-kreta.hu`;
+ }
+}
\ No newline at end of file
diff --git a/tools/createTemplate.js b/tools/createTemplate.js
new file mode 100644
index 0000000..47e91ad
--- /dev/null
+++ b/tools/createTemplate.js
@@ -0,0 +1,130 @@
+const createTemplate = {
+ header() {
+ const data = {
+ schoolInfo: {
+ name: cookieManager.get('schoolName') || 'Iskola',
+ id: cookieManager.get('schoolCode') || ''
+ },
+ userData: {
+ name: cookieManager.get('userName') || 'Felhasználó',
+ time: document.querySelector('.usermenu_timer')?.textContent?.trim() || '45:00',
+ email: cookieManager.get('userEmail') || ''
+ }
+ };
+
+ const schoolNameFull = `${data.schoolInfo.id} - ${data.schoolInfo.name}`;
+ const shortenedSchoolName = helper.shortenSchoolName(schoolNameFull);
+
+
+
+ const element = ``
+
+ // Kijelentkezés időzítő
+ const startTime = parseInt(data.userData.time?.match(/\d+/)?.[0] || "45");
+ let timeLeft = startTime * 60;
+
+ const updateTimer = () => {
+ const minutes = Math.floor(timeLeft / 60);
+ const seconds = timeLeft % 60;
+ const timerEl = document.getElementById('logoutTimer');
+ if (timerEl) {
+ timerEl.textContent = `${minutes}:${seconds.toString().padStart(2, '0')}`;
+ }
+
+ if (timeLeft <= 0) {
+ window.location.href = '/Home/Logout';
+ } else {
+ timeLeft--;
+ }
+ };
+
+ setInterval(updateTimer, 1000);
+
+ return element;
+ },
+
+ importFonts() {
+ const links = [
+ { rel: 'preconnect', href: 'https://fonts.googleapis.com' },
+ { rel: 'preconnect', href: 'https://fonts.gstatic.com', crossorigin: true },
+ { rel: 'stylesheet', href: 'https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100..900;1,100..900&display=swap' },
+ { rel: 'stylesheet', href: 'https://fonts.googleapis.com/icon?family=Material+Icons+Round' }
+ ];
+
+ links.forEach(link => {
+ const linkElement = document.createElement('link');
+ Object.entries(link).forEach(([key, value]) => {
+ linkElement[key] = value;
+ });
+ document.head.appendChild(linkElement);
+ });
+ }
+}
+
+document.addEventListener("DOMContentLoaded", async () => {
+ await helper.waitForElement('#settingsBtn');
+ document.querySelector('#settingsBtn').addEventListener('click', (e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ const url = chrome.runtime.getURL('settings/index.html');
+ window.open(url, '_blank', 'width=400,height=600');
+ });
+});
\ No newline at end of file
diff --git a/tools/helper.js b/tools/helper.js
new file mode 100644
index 0000000..bb738ec
--- /dev/null
+++ b/tools/helper.js
@@ -0,0 +1,40 @@
+const helper = {
+ shortenSchoolName(name, maxLength = 50) {
+ if (!name) return '';
+ if (name.length <= maxLength) return name;
+
+ const parts = name.split(' - ');
+ if (parts.length === 2) {
+ const [code, fullName] = parts;
+ if (fullName.length > maxLength - code.length - 3) {
+ return `${code} - ${fullName.substring(0, maxLength - code.length - 6)}...`;
+ }
+ }
+ return name.substring(0, maxLength - 3) + '...';
+ },
+
+ async waitForElement(selector) {
+ return new Promise(resolve => {
+ if (document.querySelector(selector)) {
+ return resolve(document.querySelector(selector));
+ }
+
+ const observer = new MutationObserver(mutations => {
+ if (document.querySelector(selector)) {
+ observer.disconnect();
+ resolve(document.querySelector(selector));
+ }
+ });
+
+ observer.observe(document.body, {
+ childList: true,
+ subtree: true
+ });
+ });
+ },
+
+ convertTimeToMinutes(timeStr) {
+ const [hours, minutes] = timeStr.split(':').map(Number);
+ return hours * 60 + minutes;
+ }
+}
\ No newline at end of file
diff --git a/tools/loadingScreen.css b/tools/loadingScreen.css
new file mode 100644
index 0000000..5a2703b
--- /dev/null
+++ b/tools/loadingScreen.css
@@ -0,0 +1,59 @@
+.modalBckgroundMain {
+ display: none !important;
+}
+
+body:not(.loaded) {
+ opacity: 0 !important;
+ visibility: hidden !important;
+ height: 100vh !important;
+ overflow: hidden !important;
+}
+
+.loading-screen {
+ position: fixed;
+ top: 0;
+ left: 0;
+ width: 100vw;
+ height: 100vh;
+ background-color: var(--background);
+ z-index: 9999;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ transition: opacity 0.3s ease;
+}
+
+.loading-content {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ gap: 1rem;
+}
+
+.loading-logo {
+ width: 48px;
+ height: 48px;
+ border-radius: 16px;
+}
+
+.loading-text {
+ color: var(--text-primary);
+ text-align: center;
+ font-family: Montserrat;
+ font-size: 20px;
+ font-style: normal;
+ font-weight: 700;
+ line-height: normal;
+}
+
+.loading-text2 {
+ align-self: stretch;
+ color: var(--text-secondary);
+ text-align: center;
+ font-family: Figtree;
+ font-size: 16px;
+ font-style: normal;
+ font-weight: 500;
+ line-height: 130%;
+}
diff --git a/tools/loadingScreen.js b/tools/loadingScreen.js
new file mode 100644
index 0000000..12f4469
--- /dev/null
+++ b/tools/loadingScreen.js
@@ -0,0 +1,47 @@
+const loadingScreen = {
+ show() {
+ document.body.classList.remove('loaded');
+ const existingLoadingScreen = document.querySelector('.loading-screen');
+ if (existingLoadingScreen) return;
+
+ const loadingScreen = document.createElement('div');
+ loadingScreen.className = 'loading-screen';
+ loadingScreen.innerHTML = `
+
+
})
+
Betöltés alatt...
+
Kis türelmet!
+
+ `;
+ document.body.appendChild(loadingScreen);
+ document.body.classList.add('loaded');
+ },
+
+ hide() {
+ document.body.classList.add('loaded');
+ const loadingScreen = document.querySelector('.loading-screen');
+ if (loadingScreen) {
+ loadingScreen.style.opacity = '0';
+ loadingScreen.addEventListener('transitionend', () => {
+ loadingScreen.remove();
+ });
+ }
+ }
+}
+
+window.addEventListener('DOMContentLoaded', () => {
+ const manifest = chrome.runtime.getManifest();
+ const urls = [];
+
+ if (manifest.content_scripts) {
+ manifest.content_scripts.forEach(script => {
+ if (script.matches) {
+ urls.push(...script.matches);
+ }
+ });
+ }
+
+ if (urls.some(url => url.includes(location.pathname))) {
+ loadingScreen.show();
+ }
+});
\ No newline at end of file