您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
;)
当前为
// ==UserScript== // @name Omni Image Preview // @namespace http://tampermonkey.net/ // @version 1.2.2 // @description ;) // @author You // @match https://omni.top-academy.ru/* // @icon https://www.google.com/s2/favicons?sz=64&domain=top-academy.ru // @grant none // @license MIT // ==/UserScript== var Version = "1.2.2"; var CurrentHomeworks=null; var CanOpenImage=true; var UpdateFounded=false; function CheckUpdates(){ fetch('https://gf.qytechs.cn/ru/scripts/487845-omni-image-preview', {method: 'GET'}) .then(response => response.text()) .then(data => { var versionRegex = /<dt class="script-show-version"><span>Версия<\/span><\/dt>\s+<dd class="script-show-version"><span>(.*?)<\/span><\/dd>/; var match = data.match(versionRegex); if (match) { var version = match[1]; if (version!==Version && version!=="" && UpdateFounded==false){ UpdateFounded=true; window.open('https://gf.qytechs.cn/ru/scripts/487845-omni-image-preview') } } }) .catch(error => {}); } function SendPacket(URL, Type, JSONVals){ return new Promise((resolve, reject) => { const xhr = new XMLHttpRequest(); xhr.open(Type, URL); xhr.setRequestHeader('authority', 'msapi.top-academy.ru'); xhr.setRequestHeader('method', 'POST'); xhr.setRequestHeader('path', '/api/v2/auth/login'); xhr.setRequestHeader('scheme', 'https'); xhr.setRequestHeader('Accept', 'application/json, text/plain, */*'); xhr.setRequestHeader('Accept-Language', 'ru_RU, ru'); xhr.onreadystatechange = () => { if (xhr.readyState === XMLHttpRequest.DONE) { if (xhr.status >= 200 && xhr.status < 300) { resolve(xhr.responseText); } else { reject(xhr.statusText); } } }; xhr.onerror = () => reject(xhr.statusText); if (JSONVals!==null) { xhr.setRequestHeader('Content-Type', 'application/json'); const requestBody = JSON.parse(JSONVals); xhr.send(JSON.stringify(requestBody)); } else { xhr.send(); } }); } function CreateFullscreenViewAPI(){ var FullscreenView = document.createElement('div'); FullscreenView.id="FillScreenViewer" FullscreenView.innerHTML=` <style> img#FullscreenImg { max-width: 100%; max-height: 100%; height: 80% !important; object-fit: cover; transition: all 1s;transform: translate(-50%, -50%);left: 50%;top: 50%;position: relative;height: auto;border-radius: 20px;z-index: 9000;display: block;-webkit-touch-callout: none;-webkit-user-select: none;-khtml-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;} img#FullscreenImg:hover { height: 97% !important; } .imgActiveImage{ transition: all 1s; border-radius: 20px; width: 100%; max-height: 100px; object-fit: cover; cursor: pointer; } .imgActiveImage:hover{ max-height: 150px; } div#FullscreenView {width: 100%; height: 0%; background: #252525de; position: absolute; transition: all .6s; top: 0px; z-index: 102;display: none; } </style> <div id="FullscreenView" onClick="window.CloseImageOnFullscreen()"> <img id="FullscreenImg"> </div>`; document.querySelector("body").after(FullscreenView) } function IsHomeWorksOpened(){ return document.querySelectorAll(".md-dialog-container.home_work_modal").length == 1 // Применить скрипт если окно открылось } function ShowImageIfAvaiable(){ if (IsHomeWorksOpened()){ SendPacket("https://omni.top-academy.ru/homework/get-new-homeworks", "POST", null).then(data => { data = JSON.parse(data); CurrentHomeworks=data.homework.reverse(); const downloadUrls = CurrentHomeworks.map(obj => obj.download_url_stud); const PreviewPlaces = document.querySelectorAll(".hw-md_single_stud-work__outer") if (document.getElementById("FillScreenViewer") === null){ CreateFullscreenViewAPI(); } for (var i=0; i < PreviewPlaces.length; i++){ try{ if (document.getElementById("ActiveImage"+i) !== null && document.getElementById("ActiveImage"+i).src !== downloadUrls[i]) {document.getElementById("ActiveImage"+i).src = downloadUrls[i]} if (document.getElementById("ActiveImage"+i) === null){ var ImgPreviewDiv = document.createElement('div'); ImgPreviewDiv.innerHTML=(` <img class='imgActiveImage' src=`+downloadUrls[i]+` id="ActiveImage`+i+`" onError='NotImage("ActiveImage`+i+`")' style="border-radius:20px; width:100%; cursor:pointer;" onClick="OpenImageOnFullscreen('`+downloadUrls[i]+`')"> `); PreviewPlaces[i].after(ImgPreviewDiv) } }catch(e){console.error(e)} } }) } setTimeout(ShowImageIfAvaiable, 1000) } function ProcessLoad(){ if(IsHomeWorksOpened()){ setTimeout(ShowImageIfAvaiable, 200) } else { setTimeout(ProcessLoad, 200) } } (function() { setTimeout(CheckUpdates, 60000); setInterval(CheckUpdates, 1800000);// window.CloseImageOnFullscreen = function () { if (CanOpenImage){ CanOpenImage=false; document.getElementById('FullscreenView').style.height='0%' setTimeout(function() {document.getElementById('FullscreenView').style.display='none'}, 510); setTimeout(CanOpenImage=true, 500); } }; window.OpenImageOnFullscreen = function (URL) { if (CanOpenImage){ CanOpenImage=false; document.getElementById('FullscreenView').style.display='block'; setTimeout(function() {document.getElementById('FullscreenView').style.height='100%'}, 10); document.getElementById('FullscreenImg').src=URL; setTimeout(CanOpenImage=true, 500); } }; window.NotImage = function (ID) { if (document.getElementById(ID) !== null){ document.getElementById(ID).style.display="none"; } }; ProcessLoad() })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址