Perk TV Automator

This script does things like refreshing the page and pressing the play button so that you can have a Perk TV server.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Perk TV Automator
// @namespace    Perk TV Automator
// @include      *perk.tv/*
// @supportURL   https://greasyfork.org/scripts/18031-perk-tv-automator/
// @version      3.0
// @description  This script does things like refreshing the page and pressing the play button so that you can have a Perk TV server.
// @author       Byte11
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    var refreshPageTimer = setInterval (function() {refreshPage(); }, Math.floor(Math.random() * 900000));
    var fastForwardTimer = setInterval (function() {fastForward(); }, Math.floor(Math.random() * 3000) + 7000);
    var autoLoginTimer = setInterval (function() {autoLogin(); }, Math.floor(Math.random() * 3000)); //NOTE: For this to work, you have to disable the password autofill (it's the thing that saves your password and puts it in automatically) if you enabled it on whatever browser you're using. For whatever reason, the login button doesn't work when it's enabled.
    var onHomeTimer = setInterval (function() {onHome(); }, Math.floor(Math.random() * 3000));

    function onHome() {
        if(window.location.href == "http://perk.tv/home") {
            location.href = "http://perk.tv/video/c2621eeb-be27-11e5-91e5-0025902deae0";
        }
    }

    function autoLogin() {
        var email = "DISABLE";      //NOTE: This type of storage is very insecure. Make sure your Perk password isn't shared with any other services or don't use this feature. To disable this, set the text field to DISABLE.
        var  password = "DISABLE";      //NOTE: This type of storage is very insecure. Make sure your Perk password isn't shared with any other services or don't use this feature. To disable this, set the text field to DISABLE.

        if(email == "DISABLE" || password == "DISABLE") {
        }
        else {
            if(document.getElementsByClassName("login")[0] != "none") {
                document.getElementsByClassName("login")[0].click();
            }

            document.getElementsByClassName("panel-element-input panel-element-input--email")[0].value = email;
            document.getElementsByClassName("panel-element-input panel-element-input--password")[0].value = password;

            document.getElementsByClassName("panel-element-button flex-column")[0].disabled = false;
            document.getElementsByClassName("panel-element-button flex-column")[0].click();
        }
    }

    function fastForward () {
        var duration = jwplayer().getDuration();
        var targetPos = duration - Math.random();

        jwplayer().seek(targetPos);
    }

    function refreshPage(){
        location.href = "http://perk.tv/video/c2621eeb-be27-11e5-91e5-0025902deae0";
    }
})();