FextraLife Tweaks

Various tweaks to FextraLife wiki(s).

目前為 2021-09-24 提交的版本,檢視 最新版本

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

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

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

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

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         FextraLife Tweaks
// @description  Various tweaks to FextraLife wiki(s).
// @author       Magic of Lolis <[email protected]>
// @icon         https://fextralife.com/wp-content/uploads/2015/07/flswords-152.png
// @version      0.1
// @namespace    https://github.com/magicoflolis/userscriptrepo/tree/master/FextraLifeTweaks#fextralife-tweaks
// @homepageURL  https://github.com/magicoflolis/userscriptrepo/tree/master/FextraLifeTweaks#fextralife-tweaks
// @supportURL   https://github.com/magicoflolis/userscriptrepo/issues/new
// @match        https://*.wiki.fextralife.com/*
// @grant        GM_addStyle
// ==/UserScript==

"use strict";
(() => {
  // Defaults are listed at the end of the user script.
  // Feel free to customize "Top" button (Scroll for example)
  let css = `
    top: 90%;
    left: 90%;
    font-family: inherit;
    font-size: 14px;
    font-weight: bold;
    width: auto;
    min-height: 5px;
    margin: 0 3px;
    padding: 10px 15px;
    cursor: pointer;
    text-transform: uppercase;
    text-align: center;
    position: fixed; `,
  reduce_clutter = true, // Removes some clutter + wider page
  scroll_amount = 202, // 0 to disable auto scroll AND "Top" button
  /**
  * Example = {
  * -left: 90%;
  * +left: 0%; "Top" will be moved to bottom left
  * The !important is needed for any color changes due to button matching site style.
  * +color: red !important; "Top" will have red text
  * +border: 2px solid #000 !important; "Top" will have black border with 2px width
  * ...}
  */
  btn_css = `#top-btn {${css}}`,
  qs = (element, type = "") => {
    return (type !== "all") ? document.querySelector(element) : document.querySelectorAll(element)
  },
  create = (element, type, cname, iname) => {
    let el = document.createElement(element),
    ty = (type == "button") ? (el.type = type, el.value = "Top") : (el.type = type);
    type ? ty : false;
    cname ? (el.className = cname) : false;
    iname ? (el.id = iname) : false;
    return el;
  },
  top_btn = create("input", "button", "btn btn-default btn-xs", "top-btn");
  if(reduce_clutter) {
    qs("#sidebar-wrapper").remove()
    qs("#wrapper").setAttribute("style", "padding-left: 0px !important")
    for (let i = 0; i < qs("ul", "all").length; i++) {
      qs("ul", "all")[i].setAttribute("style", "max-width: 100% !important")
    }
  }
  GM_addStyle(btn_css);
  top_btn.onclick = () => {
    return window.scroll(0, scroll_amount);
  };
  if(scroll_amount > 0) {
    qs("#wrapper").append(top_btn);
    window.scroll(0, scroll_amount);
    window.onscroll = async () => {
      (document.documentElement.scrollTop > scroll_amount) ? top_btn.setAttribute("style",'display: inline-block !important') : top_btn.setAttribute("style",'display: none !important');
    };
  }
})();

/**
* Defaults:
* 
* reduce_clutter = true // Removes some clutter + wider page
* scroll_amount = 202 // Set to 0 disables auto scroll AND "Top" button
* css = {
  top: 90%;
  left: 90%;
  font-family: inherit;
  font-size: 14px;
  font-weight: bold;
  width: auto;
  min-height: 5px;
  margin: 0 3px;
  padding: 10px 15px;
  cursor: pointer;
  text-transform: uppercase;
  text-align: center;
  position: fixed; }
*/