Greasy Fork is available in English.
美化AcWing界面
当前为
// ==UserScript==
// @name AcWing美化
// @version 0.22
// @description 美化AcWing界面
// @author 北极小狐
// @match https://www.acwing.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=acwing.com
// @grant none
// @license MIT
// @namespace http://greasyfork.icu/users/747162
// ==/UserScript==
// 调整样式
function loadCssCode(code){
var style = document.createElement('style');
style.type = 'text/css';
style.rel = 'stylesheet';
style.appendChild(document.createTextNode(code));
var head = document.getElementsByTagName('head')[0];
head.appendChild(style);
}
loadCssCode(`
/* 宽度自适应 */
.container {
width: auto !important;
}
/* 去除没用的图标 */
.file-explorer-main-field-item.file-explorer-main-field-item-desktop {
width: 0px;
height: 0px;
overflow: hidden;
}
/* 去除广告 */
#1024-activity{
width: 0px;
height: 0px;
overflow: hidden;
}
/* 其他 */
.fs-gui-taskbar {
height: 3.5vh !important;
background-color: #dde1e5 !important;
}
.fs-gui-taskbar-widgets-apps-item > img {
height: 2.2vh !important;
width: 2.2vh !important;
margin: 0.5vh 0.5vh 0.5vh 0.5vh !important;
}
.fs-gui-taskbar-widgets-clock{
width: 0px !important;
height: 0px !important;
overflow: hidden !important;
}
.fs-gui-taskbar-widgets-apps-item {
margin-right: 2vh !important;
}
#fs-gui-taskbar-search-field {
font-size: 1.3vh !important;
}
.fs-gui-taskbar-search-icon {
font-size: 1.6vh !important;
top: 0.95vh !important;
left: 4.2vh !important;
}
footer#acwing_footer .copyright {
color: #fff;
}
footer#acwing_footer .copyright a, .links a, footer#acwing_footer .container {
color: #fff;
}
.fs-gui-taskbar-begin {
height: 3vh !important;
width: 3vh !important;
margin: 0.2vh !important;
border-radius: 60%;
background-color: #fffefe80 !important;
}
button.fs-gui-taskbar-begin.pull-left.btn.btn-default img {
width: 83% !important;
}
#fs-gui-taskbar-search-field {
height: 90% !important;
margin: 0.15vh;
border-radius: 100px;
border-width: 0.2vh;
border-style: solid;
border-color: #c7d2dd;
}
#fs-gui-taskbar-search-field:focus-visible {
border-width: 0.2vh;
border-style: solid;
border-color: #8bb2d9;
outline: -webkit-focus-ring-color auto 0px;
}
`);
document.addEventListener('DOMContentLoaded', function() {
// 让某些链接在新窗口打开
var regExps = [
/常用代码模板/,
/example/,
/test/
];
var aTags = document.getElementsByTagName('a');
for (var i = 0; i < aTags.length; i++) {
for (var j = 0; j < regExps.length; j++) {
if (regExps[j].test(aTags[i].textContent)) {
aTags[i].setAttribute('target', '_blank');
break;
}
}
}
// 更换背景为bing今日壁纸
const xhr = new XMLHttpRequest();
xhr.open("GET", "https://api.allorigins.win/get?url=" + encodeURIComponent("https://www.bing.com/HPImageArchive.aspx?format=js&idx=0&n=1"), true);
xhr.onload = function() {
const data = JSON.parse(xhr.responseText);
const imageUrl = "https://bing.com" + JSON.parse(data.contents).images[0].url;
document.querySelector("#acwing_body").style.cssText += `background-image: url(${imageUrl}) !important`;
};
xhr.onerror = function() {
console.error("请求出错");
};
xhr.send();
// 自动恢复进度条
setTimeout(function() {
try {
console.log("11111111");
document.querySelector('.play-jump').click();
} catch (error) {
// do nothing
}
}, 3000);
});