// ==UserScript==
// @name 氦洛谷
// @namespace https://bbs.tampermonkey.net.cn/
// @version 1.1.3
// @description 氦洛谷
// @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 = `html{cursor:auto}nav[data-v-12f19ddc][data-v-1da2a308]{position:fixed!important;height:500px!important;cursor:move;border-radius:30px!important;border: 0.7px solid black;}div[data-v-12f19ddc]{border-radius:30px;}.color-none{border-radius:0!important;}`;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;
draggable.style.left='0px';
draggable.style.top='150px';
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-20));
if(newX>=screenWidth-draggable.offsetWidth-200){
const style3=document.createElement('style');style3.textContent = `.popup-wrap[data-v-12f19ddc][data-v-1da2a308]{margin-left:-11.2em!important;}`;document.head.append(style3);
const path=document.querySelector('path[data-v-1da2a308][data-v-12f19ddc]');
path.setAttribute('transform', 'scale(-1,1) translate(-500, 0)');
}else{
const style3=document.createElement('style');style3.textContent = `.popup-wrap[data-v-12f19ddc][data-v-1da2a308]{margin-left:3.7em!important;}`;document.head.append(style3);
const path=document.querySelector('path[data-v-1da2a308][data-v-12f19ddc]');
path.setAttribute('transform', 'scale(1,1) translate(0, 0)');
}
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]{opacity:0!important;transition:opacity 0.5s ease;}`;document.head.append(style3);
const style4=document.createElement('style');style4.textContent = `a[data-v-0640126c][data-v-639bc19b][data-v-1da2a308]:hover .text[data-v-639bc19b]{opacity:1!important;transition:0.5s;}`;document.head.append(style4);
}),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;
draggable.style.left='0px';
draggable.style.top='150px';
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);
}
})();
/*
旋转:flex-direction
*/