AcWing美化

美化AcWing界面

当前为 2023-04-27 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         AcWing美化
// @version      0.21
// @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 https://greasyfork.org/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;
}
.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: 16px !important;
}
#fs-gui-taskbar-search-field {
    font-size: 1.3vh !important;
}
.fs-gui-taskbar-search-icon {
    font-size: 1.6vh !important;
    top: 9.8px !important;
    left: 44.5px !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: 32px !important;
    width: 32px !important;
    margin: 1px !important;
    border-radius: 60%;
    background-color: #fffefe80 !important;
}

`);


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);
});