Advanced Streaming for aniworld & s.to

Minimize page elements to fit smaller screens and added some QoL.

目前為 2022-08-04 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Advanced Streaming for aniworld & s.to
// @namespace    https://greasyfork.org/users/928242
// @version      0.9
// @description  Minimize page elements to fit smaller screens and added some QoL.
// @author       Kamikaze (https://github.com/Kamiikaze)
// @iconURL      https://s.to/favicon.ico
// @match        https://s.to/serie/stream/*
// @match        https://serien.sx/serie/stream/*
// @match        https://anicloud.io/anime/stream/*
// @match        https://aniworld.to/anime/stream/*
// @grant        none
// @license      MIT
// ==/UserScript==

function addGlobalStyle(css) {
    var head, style;
    head = document.getElementsByTagName('head')[0];
    if (!head) { return; }
    style = document.createElement('style');
    style.type = 'text/css';
    style.innerHTML = css.replace(/;/g, ' !important;');
    head.appendChild(style);
}

function shortWindowTitle() {
    const windowTitleArray = window.document.title.split(" von ")

    const season = "S" + windowTitleArray[0].split(" ").slice(1,2)
    const episode = "E" + windowTitleArray[0].split(" ").slice(3,4)

    const name = windowTitleArray[1].split("|")[0]
    const site = windowTitleArray[1].split("|")[1].split(" - ")[0]

    window.document.title = `${season}${episode} - ${name} | ${site}`
}

shortWindowTitle()

function hideSeasonSuggestions() {
    document.querySelector(".ContentContainerBox").style = "display: none;"
}
hideSeasonSuggestions()

// FIX: Force closing Dropdown Menu on MouseLeave
function closeMenuOnHoverLeave() {
    const menu = document.querySelector(".dd")
    const modal = document.querySelector(".modal")

    menu.addEventListener('mouseleave', () => {
        modal.style = "display:none"
    })
}

closeMenuOnHoverLeave()

// Sticky-Top Episode List
// addGlobalStyle('div#stream > ul:nth-of-type(2) { position: fixed; top: 0; width: 100%; z-index: 99; }');

addGlobalStyle(`

/* Reduce Height of Video player */
.inSiteWebStream, .inSiteWebStream iframe {
    height: 150px;
}

.hosterSiteTitle {
    padding: 5px 0 10px;
}

/* Hiding unnecessary page elements (Editing Descripting, Language Box..) and already seen episodes  */
.descriptionSpoilerLink, .descriptionSpoilerPlaceholder,
.submitNewDescription, .hosterSectionTitle, .changeLanguageBox,
#stream > ul:nth-child(4) li .seen {
    display: none;
}

`);


function addAnimeSearchBox() {
    const rightColEl = document.getElementsByClassName("add-series")[0]
    const seriesTitel = document.querySelector("div.series-title > h1 > span").innerText
    const searchBoxEl = document.createElement('div')
    searchBoxEl.classList.add('anime-search')
    const searchBoxTitel = document.createElement('p')
    searchBoxTitel.innerText = "Search Anime at:"

    rightColEl.append(searchBoxEl)
    searchBoxEl.append(searchBoxTitel)

    const sites = [
        {icon: "https://www.google.com/s2/favicons?sz=64&domain=crunchyroll.com", searchUrl: "https://www.crunchyroll.com/de/search?q=#TITEL#", name: "Crunchyroll" },
        {icon: "https://www.google.com/s2/favicons?sz=64&domain=anisearch.de", searchUrl: "https://www.anisearch.de/anime/index?text=#TITEL#", name: "aniSearch" },
        {icon: "https://www.google.com/s2/favicons?sz=64&domain=anime-planet.com", searchUrl: "https://www.anime-planet.com/anime/all?name=#TITEL#", name: "anime-planet" },
        {icon: "https://www.google.com/s2/favicons?sz=64&domain=myanimelist.net", searchUrl: "https://myanimelist.net/anime.php?q=#TITEL#&cat=anime", name: "MyAnimeList" },
    ]

    for (let i = 0; i < sites.length; i++) {
        const site = sites[i]
        const siteElement = document.createElement('a');
        siteElement.classList.add("sites")
        siteElement.target = "_blank"
        siteElement.href = site.searchUrl.replace("#TITEL#", seriesTitel)
        siteElement.innerHTML = `<img src="${site.icon}"/>` + site.name

        searchBoxEl.append(siteElement)
        console.log(siteElement)

    }
}

addAnimeSearchBox()



addGlobalStyle(`

.anime-search {
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    margin: 15px 5px;
    background: #313d4f;
    padding: 15px;
    border-radius: 3px;
    width: fit-content;
    position: fixed;
    left: 0;
    bottom: -8px;
}

.anime-search .sites {
    padding: 5px 0;
}

.anime-search .sites img {
    max-width: 32px;
    width: 16px;
    margin-right: 5px;
    border-radius: 16px;
}

`)