洛谷弹窗
目前為
// ==UserScript==
// @name Luogu Popwindow
// @namespace http://tampermonkey.net/
// @version 1.0.0
// @description 洛谷弹窗
// @author sxl701817
// @match https://www.luogu.com.cn/*
// @icon https://s21.ax1x.com/2024/12/14/pAqEr9S.png
// @resource sweetcss https://cdnjs.cloudflare.com/ajax/libs/sweetalert2/11.14.5/sweetalert2.min.css
// @require https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js
// @require https://cdnjs.cloudflare.com/ajax/libs/sweetalert2/11.14.5/sweetalert2.min.js
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_getResourceText
// @grant GM_addStyle
// @license MIT
// ==/UserScript==
// <i class="fa-regular fa-message"></i>
let oldhref = 'kkkfc0114514'
let css = GM_getResourceText('sweetcss')
GM_addStyle(css)
GM_addStyle('.top-bar #luogu_popwindow_setting{margin-right:8pt;}#luogu_popwindow_setting:not(.top-bar *){margin-right:5pt;}.top-bar .user-nav > #luogu_popwindow_setting:hover{background-color: rgba(0, 0, 0, .05);padding:3pt 3pt 3pt 3pt;margin-right:5pt;border-radius:3px}#luogu_popwindow_setting:hover > svg > path{fill: #0366d6;}')
let obs = new MutationObserver((muts,obs)=>{
muts.forEach((ele)=>{
if($('[currenttemplate="RecordShow"] section div .info-rows:last-child div:nth-child(2) span:last-child span').text().trim() === 'Accepted') {
swal.fire({
icon:"info",
title:"你通过了此题!",
html:GM_getValue('message','')
})
obs.disconnect()
}
})
});
setInterval(() => {
$(()=>{
if(window.location.href.search("https://www.luogu.com.cn/record/") === 0 && window.location.href !== oldhref) {
let dom = document.querySelector('[currenttemplate="RecordShow"] section div .info-rows:last-child div:nth-child(2) span:last-child span')
obs.observe(dom,{characterData:true,attributes:true})
}
if($('#luogu_popwindow_setting').length === 0) {
let dom = '<botton id="luogu_popwindow_setting" class="fa-regular fa-message"><svg class="svg-inline--fa fa-message xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M160 368c26.5 0 48 21.5 48 48l0 16 72.5-54.4c8.3-6.2 18.4-9.6 28.8-9.6L448 368c8.8 0 16-7.2 16-16l0-288c0-8.8-7.2-16-16-16L64 48c-8.8 0-16 7.2-16 16l0 288c0 8.8 7.2 16 16 16l96 0zm48 124l-.2 .2-5.1 3.8-17.1 12.8c-4.8 3.6-11.3 4.2-16.8 1.5s-8.8-8.2-8.8-14.3l0-21.3 0-6.4 0-.3 0-4 0-48-48 0-48 0c-35.3 0-64-28.7-64-64L0 64C0 28.7 28.7 0 64 0L448 0c35.3 0 64 28.7 64 64l0 288c0 35.3-28.7 64-64 64l-138.7 0L208 492z"/></svg></botton>'
$('.user-nav nav').prepend(dom)
$('.user-nav:has(> a)').prepend(dom)
$('#luogu_popwindow_setting').click(() => {
swal.fire({
icon:"question",
title:"请输入提示信息",
html:`<input type="text" value="${GM_getValue('message','')}" id="lgp_text" style="height:1.5em;width:21em;"></input>`,
showCancelButton: true
}).then((result)=>{
if(result.value) {
GM_setValue('message',$('#lgp_text').val())
swal.fire({
icon:"success",
title:"修改成功",
timer:1000,
showConfirmButton: false
})
}
})
})
}
oldhref = window.location.href
})
},200)