diff --git a/glowna.js b/glowna.js index fb17eba..b25ba6d 100644 --- a/glowna.js +++ b/glowna.js @@ -16,16 +16,16 @@ chrome.storage.local.get({ document.addEventListener("DOMContentLoaded", function() { -var szczesliwyNum = document.getElementsByClassName("szczesliwy-numerek")[0].children[0].textContent; -var teksik = document.getElementsByClassName("szczesliwy-numerek")[0].parentElement.children[2].textContent; -localStorage.setItem("szczesliwy", szczesliwyNum); -localStorage.setItem("szczesliwytex", teksik); -var tb = document.getElementById("top-banner-container").children[0]; -var myheader = document.createElement('p1'); -myheader.style.position = "absolute"; -myheader.style.top = "85%"; -myheader.textContent = teksik + szczesliwyNum; -tb.insertBefore(myheader, tb.firstChild); +//var szczesliwyNum = document.getElementsByClassName("szczesliwy-numerek")[0].children[0].textContent; +//var teksik = document.getElementsByClassName("szczesliwy-numerek")[0].parentElement.children[2].textContent; +//localStorage.setItem("szczesliwy", szczesliwyNum); +//localStorage.setItem("szczesliwytex", teksik); +//var tb = document.getElementById("top-banner-container").children[0]; +//var myheader = document.createElement('p1'); +//myheader.style.position = "absolute"; +//myheader.style.top = "85%"; +//myheader.textContent = teksik + szczesliwyNum; +//tb.insertBefore(myheader, tb.firstChild); chrome.storage.local.get({ glowna: true diff --git a/loginfix.js b/loginfix.js new file mode 100644 index 0000000..f6f3553 --- /dev/null +++ b/loginfix.js @@ -0,0 +1,9 @@ +var ramkaLogowania = document.getElementById("caLoginIframe"); +function HandleLoad(){ + ramkaLogowania.removeEventListener('load', HandleLoad); + setTimeout(function(){ + ramkaLogowania.src = ramkaLogowania.src; + }, 100); +} + +ramkaLogowania.addEventListener('load', HandleLoad); \ No newline at end of file diff --git a/manifest.json b/manifest.json index afd772e..435f0fb 100644 --- a/manifest.json +++ b/manifest.json @@ -3,7 +3,7 @@ "name": "Edziennik-plus", "description": "Więcej funkcji w dzienniku elektronicznym", - "version": "0.3.5", + "version": "0.4.0", "icons": {"128":"icon.png"}, "author": "MS", "options_ui": { @@ -21,7 +21,7 @@ "run_at": "document_start" }, { - "matches": ["https://synergia.librus.pl/uczen_index"], + "matches": ["https://synergia.librus.pl/uczen/index"], "js": ["glowna.js"], "run_at": "document_start" }, @@ -36,10 +36,9 @@ "run_at": "document_idle" }, { - "matches": ["https://synergia.librus.pl/*"], - "exclude_matches": ["https://synergia.librus.pl/uczen_index"], - "js": ["szczesliwy.js"], - "run_at": "document_end" + "matches": ["https://portal.librus.pl/rodzina/synergia/loguj"], + "js": ["loginfix.js"], + "run_at": "document_idle" } ], "permissions": [ @@ -47,7 +46,8 @@ "tabs", "webRequest", "webRequestBlocking", - "https://synergia.librus.pl/*" + "https://synergia.librus.pl/*", + "https://portal.librus.pl/*" ], "background": { "scripts": ["tlo.js"] diff --git a/tlo.js b/tlo.js index 61f520f..9ee6858 100644 --- a/tlo.js +++ b/tlo.js @@ -13,3 +13,42 @@ browser.webRequest.onHeadersReceived.addListener( {urls: ["https://synergia.librus.pl/przegladaj_plan_lekcji", "http://synergia.librus.pl/przegladaj_plan_lekcji"]}, ["blocking", "responseHeaders"] ); + +function zmienNaglowekdwa(req) { + for (var i = 0, leng = req.responseHeaders.length; i < leng; i++){ + if (req.responseHeaders[i].name == "Location"){ + req.responseHeaders[i].value = "https://portal.librus.pl/rodzina/synergia/loguj"; + } + } + return {responseHeaders: req.responseHeaders}; +} + +browser.webRequest.onHeadersReceived.addListener( + zmienNaglowekdwa, + {urls: ["https://synergia.librus.pl/wyloguj"]}, + ["blocking", "responseHeaders"] +); + +function zmienRzadanie(req) { + var zmiana = 0; + for(var header of req.requestHeaders){ + if(header.name == "Referer"){ + header.value = "https://portal.librus.pl/rodzina" + zmiana = 1; + } + } + if(zmiana == 0){ + var nowyhead = { + "name": "Referer", + "value": "https://portal.librus.pl/rodzina" + }; + req.requestHeaders.push(nowyhead); + } + return {requestHeaders: req.requestHeaders}; +} + +browser.webRequest.onBeforeSendHeaders.addListener( + zmienRzadanie, + {urls: ["https://portal.librus.pl/rodzina/synergia/loguj"]}, + ["blocking", "requestHeaders"] +); \ No newline at end of file