AcWing美化

美化AcWing界面

目前為 2023-04-27 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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);
});