Crunchyroll Auto Skip Intro & Fullscreen Video

Automatically clicks the Skip Intro button on Crunchyroll.com when available and makes the video fullscreen

目前為 2022-10-17 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Crunchyroll Auto Skip Intro & Fullscreen Video
// @namespace    https://greasyfork.org/en/users/807108-jeremy-r
// @version      3.2
// @description  Automatically clicks the Skip Intro button on Crunchyroll.com when available and makes the video fullscreen
// @author       JRem
// @require      https://cdn.jsdelivr.net/gh/mlcheng/js-toast@ebd3c889a1abaad615712485ce864d92aab4c7c0/toast.min.js
// @match        https://beta.crunchyroll.com/watch/*
// @match        https://static.crunchyroll.com/vilos-v2/web/vilos/player.html
// @grant        GM_addStyle
// @license MIT
// ==/UserScript==

// Toast Vars

const options = {
      settings: {
        duration: 3000,

      },
      style: {
        main: {
          background: "black",
          color: "white",
          width: "auto",
          'max-width': '10%',
        }
      }
};

// Volume Control via mouse scroll
// 1 Scroll = 5%
function triggerKeypress(e){
  e.preventDefault()
  const keyName = e.deltaY < 0 ? "ArrowUp" : "ArrowDown"
  const event = new KeyboardEvent("keydown", {
      key: keyName,
      bubbles: true,
      cancelable: true
  });

  document.dispatchEvent(event)
  iqwerty.toast.toast(keyName, options);
}

document.addEventListener('keydown', function(e) {
    console.log(e.key + " pressed");
});

document.getElementById("vilos").addEventListener("wheel", triggerKeypress);


// Fullscreen Video Code

window.onload = function(){
    setTimeout(function () {
        var css = '.video-player-wrapper { max-height: calc(100vh - 5.625rem) !important; height: calc(100vh) !important; }';
            css += '.erc-header { flex: 0 0 1.55rem !important; }';
            css += '.erc-header .header-content { height: 0 !important; }';
        GM_addStyle(css);
    }, 5000);
    iqwerty.toast.toast('Fullscreen added', options);
};


// Backup Fullscreen CSS Edit (Depending on page load will execute before the above)
setTimeout(function () { var css = '.video-player-wrapper { max-height: calc(100vh - 5.625rem) !important; height: calc(100vh) !important; }'; css += '.erc-header { flex: 0 0 1.55rem !important; }'; css += '.erc-header .header-content { height: 0 !important; }'; GM_addStyle(css);}, 5000);

// Functions for Mouse click emulation
function simulate(element, eventName){
    var options = extend(defaultOptions, arguments[2] || {});
    var oEvent, eventType = null;

    for (var name in eventMatchers)
    {
        if (eventMatchers[name].test(eventName)) { eventType = name; break; }
    }

    if (!eventType)
        throw new SyntaxError('Only HTMLEvents and MouseEvents interfaces are supported');

    if (document.createEvent)
    {
        oEvent = document.createEvent(eventType);
        if (eventType == 'HTMLEvents')
        {
            oEvent.initEvent(eventName, options.bubbles, options.cancelable);
        }
        else
        {
            oEvent.initMouseEvent(eventName, options.bubbles, options.cancelable, document.defaultView,
            options.button, options.pointerX, options.pointerY, options.pointerX, options.pointerY,
            options.ctrlKey, options.altKey, options.shiftKey, options.metaKey, options.button, element);
        }
        element.dispatchEvent(oEvent);
    }
    else
    {
        options.clientX = options.pointerX;
        options.clientY = options.pointerY;
        var evt = document.createEventObject();
        oEvent = extend(evt, options);
        element.fireEvent('on' + eventName, oEvent);
    }
    return element;
};

function extend(destination, source) {
    for (var property in source)
      destination[property] = source[property];
    return destination;
};

var eventMatchers = {
    'HTMLEvents': /^(?:load|unload|abort|error|select|change|submit|reset|focus|blur|resize|scroll)$/,
    'MouseEvents': /^(?:click|dblclick|mouse(?:down|up|over|move|out))$/
};
var defaultOptions = {
    pointerX: 0,
    pointerY: 0,
    button: 0,
    ctrlKey: false,
    altKey: false,
    shiftKey: false,
    metaKey: false,
    bubbles: true,
    cancelable: true
};

// Check for and click Skip Intro
setInterval(function () {
   if(document.querySelector('div[data-testid="skipIntroText"]') !== null) {
        simulate(document.querySelector('div[data-testid="skipIntroText"]'), "click");
        console.log('Skip Btn Found');
        iqwerty.toast.toast('Intro Skipped', options);
    }
}, 1000)