CosmosisT's Black Camera Fix Script

Modified TinyChat - Best Scripts; prepare to be amazed.

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 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);
})();