CosmosisT's Black Camera Fix Script

Modified TinyChat - Best Scripts; prepare to be amazed.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        CosmosisT's Black Camera Fix Script
// @version     1.1
// @description Modified TinyChat - Best Scripts; prepare to be amazed.
// @author      CosmosisT
// @url         https://gist.github.com/CosmosisT
// @license     Copyright (C) 2019-2020 CosmosisT
// @icon        https://tinychat.com/webrtc/2.0.0-81/images/favicon.png
// @match       https://tinychat.com/room/*
// @match       https://tinychat.com/*
// @exclude     https://tinychat.com/settings/*
// @exclude     https://tinychat.com/subscription/*
// @exclude     https://tinychat.com/promote/*
// @exclude     https://tinychat.com/coins/*
// @exclude     https://tinychat.com/gifts*
// @grant       none
// @run-at      document-start
//              jshint esversion: 6
// @namespace https://greasyfork.org/users/395685
// ==/UserScript==

(function() {
    'use strict';
    var e=0,
        i,
        error_code = ["Timeout"];
    var CTS = {
        Init: function() {
            e++;
            if(CTS.PageLoaded()) {
                CTS.Dispose();
                window.TinychatApp.BLL.ChatRoom.prototype.sendPushForUnreadPrivateMessage = function() {};
                window.TinychatApp.BLL.Videolist.prototype.blurOtherVids = function() {};
                window.TinychatApp.BLL.User.isSubscription = function() {return true;};
                window.TinychatApp.BLL.User.canUseFilters = function() {return true;};
                window.TinychatApp.BLL.MediaConnection.prototype.Close = function() {
                    if (this.rtc !== null) {
                        let a = this.rtc;
                        this.rtc = null;
                        if (this.mediaStream !== null) {
                            if (this.mediaStream.active && a.signalingState !== "closed" && typeof a.removeStream === "function" && a.removeStream(this.mediaStream)) {
                                this.mediaStream.stop();
                                this.mediaStream = null;
                            }
                        } else {
                            this.videolist.RemoveVideoRemote(this.handle);
                        }
                        if (a.signalingState !== "closed" && a.close()) {
                            console.log("MediaConnection.SignalingState: " + a.signalingState + " ->>> Close");
                        }
                    }
                };
            } else {
                if(e >= 20) CTS.Flag(0);
            }
        },
        PageLoaded: function() {
            console.log("Hoist Attempt: "+e);
            if (document.querySelector("tinychat-webrtc-app")) {
                if (document.querySelector("tinychat-webrtc-app").shadowRoot) return true;
            }
        },
        Dispose: function() {
            clearInterval(i);
        },
        Flag: function(err, caught) {
            CTS.Dispose();
            console.log("Error: "+error_code[err]);
        }
    };

    i = setInterval(CTS.Init, 500);
})();