diff --git a/SfeduHelper/grade.js b/SfeduHelper/grade.js new file mode 100644 index 0000000..832a58c --- /dev/null +++ b/SfeduHelper/grade.js @@ -0,0 +1,18 @@ +if (document.getElementById('signoauthin_b')) { + document.getElementById('signoauthin_b').addEventListener('click', function () { + if (document.getElementById("loginoauth").value.toLowerCase().match(/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|.(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/ + )) { + chrome.storage.local.set({ "email": document.getElementById("loginoauth").value }, function () { + console.log('Email сохранен'); + }); + } else { + console.log("Не удалось сохранить email"); + } + }); + + chrome.storage.local.get(["email"], function (items) { + if (items["email"] != undefined && document.getElementById("loginoauth").value == "") { + document.getElementById("loginoauth").value = items["email"]; + } + }); +} \ No newline at end of file diff --git a/SfeduHelper/icons/iconDis128.png b/SfeduHelper/icons/iconDis128.png new file mode 100644 index 0000000..2b4d362 Binary files /dev/null and b/SfeduHelper/icons/iconDis128.png differ diff --git a/SfeduHelper/icons/iconDis64.png b/SfeduHelper/icons/iconDis64.png new file mode 100644 index 0000000..15d35c3 Binary files /dev/null and b/SfeduHelper/icons/iconDis64.png differ diff --git a/SfeduHelper/icons/iconEn128.png b/SfeduHelper/icons/iconEn128.png new file mode 100644 index 0000000..b33f8c3 Binary files /dev/null and b/SfeduHelper/icons/iconEn128.png differ diff --git a/SfeduHelper/icons/iconEn64.png b/SfeduHelper/icons/iconEn64.png new file mode 100644 index 0000000..36372b8 Binary files /dev/null and b/SfeduHelper/icons/iconEn64.png differ diff --git a/SfeduHelper/icons/trash.svg b/SfeduHelper/icons/trash.svg new file mode 100644 index 0000000..ad817f1 --- /dev/null +++ b/SfeduHelper/icons/trash.svg @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/SfeduHelper/manifest.json b/SfeduHelper/manifest.json new file mode 100644 index 0000000..599dc10 --- /dev/null +++ b/SfeduHelper/manifest.json @@ -0,0 +1,32 @@ +{ + "name": "Sfedu Helper", + "description": "Расширение для упрощения работы с сайтами Sfedu", + "version": "1.0", + "manifest_version": 3, + "icons": { + "64": "icons/iconEn64.png", + "128": "icons/iconEn128.png" + }, + "action": { + "default_popup": "popup.html" + }, + "permissions": [ + "storage", + "activeTab", + "tabs" + ], + "content_scripts": [ + { + "matches": [ + "https://grade.sfedu.ru/", "https://grade.sfedu.ru/sign" + ], + "js": [ + "grade.js" + ] + } + ], + "background": { + "service_worker": "service_worker.js", + "type": "module" + } +} \ No newline at end of file diff --git a/SfeduHelper/popup.css b/SfeduHelper/popup.css new file mode 100644 index 0000000..3b36ef4 --- /dev/null +++ b/SfeduHelper/popup.css @@ -0,0 +1,99 @@ +body { + width: 200px; + height: 150px; +} + +h1 { + text-align: center; +} + +#main { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; +} + +#clearBtn { + color: white; + background-color: #4272e1; + width: 80%; + height: 35px; + margin-bottom: 10px; + border-radius: 20px; + border: none; + display: flex; + justify-content: center; + align-items: center; +} + +#clearBtn:hover { + background-color: #003ece; +} + +img { + width: 20px; + height: 20px; + margin-right: 5px; +} + +#version { + color: gray; + display: flex; + justify-content: center; + align-items: center; +} + +.notif { + position: fixed; + left: 15px; + bottom: -50px; + padding: 8px 15px 8px 15px; + vertical-align: middle; + color: #fff; + background-color: #38bc73; + box-shadow: 0 6px 15px rgba(0, 0, 0, 0.2); + border-radius: 20px; + font-family: "Trebuchet MS", Helvetica, sans-serif; +} + +.peek { + -webkit-animation: peek 2.5s forwards; + animation: peek 2.5s forwards; +} + +@-webkit-keyframes peek { + 0% { + bottom: -50px; + } + + 20% { + bottom: 15px; + } + + 90% { + bottom: 15px; + } + + 100% { + bottom: -50px; + } +} + +@keyframes peek { + 0% { + bottom: -90px; + } + + 20% { + bottom: 15px; + } + + 90% { + bottom: 15px; + } + + 100% { + bottom: -50px; + } +} \ No newline at end of file diff --git a/SfeduHelper/popup.html b/SfeduHelper/popup.html new file mode 100644 index 0000000..89b1967 --- /dev/null +++ b/SfeduHelper/popup.html @@ -0,0 +1,20 @@ + + + + + + Sfedu Helper + + + + + +
+

Sfedu Helper

+ +

V 1.0.0

+
+ + + + \ No newline at end of file diff --git a/SfeduHelper/popup.js b/SfeduHelper/popup.js new file mode 100644 index 0000000..0548d02 --- /dev/null +++ b/SfeduHelper/popup.js @@ -0,0 +1,10 @@ +document.addEventListener('DOMContentLoaded', function() { + var checkButton = document.getElementById('clearBtn'); + checkButton.addEventListener('click', function() { + chrome.storage.local.clear(function () { + var popup = document.getElementById("popup"); + popup.innerHTML = "
OK
"; + }); + + }, false); + }, false); \ No newline at end of file diff --git a/SfeduHelper/service_worker.js b/SfeduHelper/service_worker.js new file mode 100644 index 0000000..bd24f80 --- /dev/null +++ b/SfeduHelper/service_worker.js @@ -0,0 +1,30 @@ +chrome.tabs.onUpdated.addListener(function (tabId, changeInfo, tab) { + // Получить URL текущей вкладки + var url = tab.url; + var manifestData = chrome.runtime.getManifest(); + var enabled = false; + manifestData.content_scripts[0].matches.forEach((element) => { + console.log(element + " " + url.includes(element)); + enabled = url.includes(element) + }); + if (enabled) { + chrome.action.setIcon({ path: { + "64" : "icons/iconEn64.png", + "128" : "icons/iconEn128.png" + }, tabId: tabId }); + // Установить обработчик клика по иконке + chrome.action.onClicked.addListener(function (tab) { + // Выполнить какое-то действие при клике + }); + } else { + chrome.action.setIcon({ path: { + "64" : "icons/iconDis64.png", + "128" : "icons/iconDis128.png" + }, tabId: tabId }); + // Установить обработчик клика по иконке + chrome.action.onClicked.addListener(function (tab) { + // Показать alert при клике + alert("This extension is not available for this page"); + }); + } +}); \ No newline at end of file