// ==UserScript== // @name 氦洛谷 // @namespace https://bbs.tampermonkey.net.cn/ // @version 0.1.2 // @description try to take over the world! // @author You // @match *://www.luogu.com.cn/* // @match *://www.luogu.com/* // @exclude https://www.luogu.com.cn // ==/UserScript== (function() { 'use strict'; const element=document.querySelector('.sidebar.lside.bar.hide.nav-scrollbar'); const maincolor="#8e44ad"; if(!element){ setTimeout((function(){ console.log('%c[note] This is old luogu.','color:orange;'); const newHTML=`
设置
`; const element=document.querySelector('nav[data-v-258e49ac][data-v-2dfcfd35]'); element.insertAdjacentHTML('afterbegin', newHTML); const div=document.getElementById('setting'); div.addEventListener('click', function(event){ window.open('/setting'); }); const style1=document.createElement('style');style1.textContent = `nav[data-v-12f19ddc][data-v-1da2a308]{position:fixed!important;height:500px!important;cursor: move;}`;document.head.append(style1); const style2=document.createElement('style');style2.textContent = `.main-container{margin-left:0px!important;}`;document.head.append(style2); const draggable = document.querySelector('nav[data-v-12f19ddc][data-v-1da2a308]'); let offsetX=0; let offsetY=0; let isDragging = false; draggable.addEventListener('mousedown', function(e) { isDragging = true; offsetX = e.clientX - draggable.offsetLeft; offsetY = e.clientY - draggable.offsetTop; document.body.style.userSelect = 'none'; }); document.addEventListener('mousemove', function(e) { if (isDragging) { const screenWidth = window.innerWidth; const screenHeight = window.innerHeight; let newX=e.clientX - offsetX; let newY=e.clientY - offsetY; newX=Math.max(0, Math.min(newX, screenWidth-draggable.offsetWidth-200)); newY=Math.max(0, Math.min(newY, screenHeight-draggable.offsetHeight)); draggable.style.left=newX+'px'; draggable.style.top=newY+'px'; } }); document.addEventListener('mouseup', function() { isDragging = false; document.body.style.userSelect = ''; }); const style3=document.createElement('style');style3.textContent = `.text[data-v-639bc19b]{visibility:hidden!important;}`;document.head.append(style3); style3=document.createElement('style');style3.textContent = `a[data-v-0640126c][data-v-639bc19b][data-v-1da2a308]:hover .text[data-v-639bc19b]{visibility:visible!important;}`;document.head.append(style3); }),500); }else{ setTimeout((function(){ console.log('%c[note] This is new luogu.','color:orange;'); const newHTML=`
设置
`; const element=document.querySelector('div[data-v-c1098b6a][data-v-0cbb2f60].user-nav'); element.insertAdjacentHTML('afterbegin', newHTML); const div=document.getElementById('setting'); div.addEventListener('click', function(event){ window.open('/setting'); }); const style1=document.createElement('style');style1.textContent = `nav[data-v-06583f34][data-v-0cbb2f60]{position:fixed!important;height:500px!important;cursor:move;}`;document.head.append(style1); const style2=document.createElement('style');style2.textContent = `.main-container{margin-left:0px!important;width:100%!important;}`;document.head.append(style2); const draggable = document.querySelector('nav[data-v-06583f34][data-v-0cbb2f60]'); let offsetX=0; let offsetY=0; let isDragging = false; draggable.addEventListener('mousedown', function(e) { isDragging = true; offsetX = e.clientX - draggable.offsetLeft; offsetY = e.clientY - draggable.offsetTop; document.body.style.userSelect = 'none'; }); document.addEventListener('mousemove', function(e) { if (isDragging) { const screenWidth = window.innerWidth; const screenHeight = window.innerHeight; let newX=e.clientX - offsetX; let newY=e.clientY - offsetY; newX=Math.max(0, Math.min(newX, screenWidth-draggable.offsetWidth-250)); newY=Math.max(50, Math.min(newY, screenHeight-draggable.offsetHeight)); draggable.style.left=newX+'px'; draggable.style.top=newY+'px'; } }); document.addEventListener('mouseup', function() { isDragging = false; document.body.style.userSelect = ''; }); }),2000); } })();