Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name meklin
- // @version 1.8.50
- // @description Modified TinyChat - Best Scripts; prepare to be amazed.
- // @author CosmosisT
- // @url https://gist.github.com/CosmosisT
- // @license Copyright (C) CosmosisT
- // @icon https://i.imgur.com/XlkFjOK.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";
- //DEBUGGER
- window.TinychatApp.BLL.MediaConnection.prototype.Close = function() {
- RTC(this);
- };
- window.TinychatApp.BLL.ChatRoom.prototype.sendPushForUnreadPrivateMessage = function() {};
- if (!CTS.Project.isTouchScreen) {
- window.TinychatApp.BLL.ChatRoom.prototype.BroadcastStart = function(a) {
- var b = this,
- d = this.settings.getSettings();
- if (d.video === null) {
- return void this.app.MediaSettings(() => {
- this.BroadcastStart();
- });
- }
- this.videolist.AddingVideoSelf(this.self_handle);
- var e = {};
- if (!navigator.mediaDevices || !navigator.mediaDevices.enumerateDevices) {
- e.audio = true;
- e.video = { width: { min: 960, max: 960 }, height: { min: 720, max: 720 }, frameRate: { min: 30, ideal: 30, max: 60 } };
- } else {
- navigator.mediaDevices.enumerateDevices().then(g => {
- var h = false;
- var len = g.length;
- for (var c = 0; c < len; c++) {
- if (g[c].kind === "videoinput") {
- if (e.video === void 0) e.video = {width: {min: 960,max: 960,height: {min: 720,max: 720},frameRate: {min: 30, ideal: 30,max: 60}};
- if (h) {
- d.video = g[c];
- h = false;
- this.settings.saveSettings(d);
- } else if (d.video === null) {
- d.video = g[c];
- this.settings.saveSettings(d);
- } else if (d.video !== null && typeof d.video == "object" && d.video.deviceId == g[c].deviceId && d.video.deviceId !== a) {
- e.video.deviceId = {exact: d.video.deviceId};
- } else if (d.video.deviceId === a) {
- h = true;
- }
- }
- if (g[c].kind === "audioinput") {
- if (e.audio === void 0) e.audio = {};
- if (d.audio !== null && typeof d.audio == "object" && d.audio.deviceId == g[c].deviceId) e.audio = {deviceId: {exact: d.audio.deviceId}};
- }
- }
- if (e.video !== null && d.video !== null && d.video.deviceId == b.id__miconly) delete e.video;
- let i = navigator.mediaDevices.getSupportedConstraints();
- for (let a in i) {
- if (i.hasOwnProperty(a) && "echoCancellation" == a && e.audio) e.audio[a] = this.settings.isAcousticEchoCancelation();
- }
- if (!(e.audio || e.video)) {
- b.onMediaFailedCallback(new Error("No media devices to start broadcast."));
- } else if ("https:" === location.protocol || this.app.isDebug()) {
- debug("BROADCAST", "Initiating Media...");
- var m = new window.TinychatApp.BLL.BroadcastProgressEvent(window.TinychatApp.BLL.BroadcastProgressEvent.MEDIA_START);
- this.EventBus.broadcast(window.TinychatApp.BLL.BroadcastProgressEvent.ID, m);
- b.mediaLastConstraints = e;
- navigator.mediaDevices.getUserMedia(e).then(m => {
- b.onMediaSuccessCallback(m);
- });
- }
- }).catch(er => {
- debug("CAMERA::ERROR", er);
- });
- }
- };
- }
- window.TinychatApp.BLL.Userlist.prototype.ignore = function(a) {
- var b = ((a.isUsername) ? a.username : a.nickname);
- if (this.isIgnored(a) || this.ignored.push(b)) {
- var c = new window.TinychatApp.BLL.IgnorelistUpdateUserEvent(a);
- this.EventBus.broadcast(window.TinychatApp.BLL.IgnorelistUpdateUserEvent.ID, c);
- this.app.showToast(b + " ignored successfully till they leave or you refresh!");
- if (!a.isUsername) {
- CTS.TempIgnoreNickList.push(b.toUpperCase());
- } else {
- CTS.TempIgnoreUserList.push(b.toUpperCase());
- }
- }
- };
- window.TinychatApp.BLL.Userlist.prototype.unignore = function(a) {
- var b = ((a.isUsername) ? a.username : a.nickname),
- index = this.ignored.indexOf(b);
- if (index != -1) this.ignored.splice(index, 1);
- if (!a.isUsername) {
- index = CTS.TempIgnoreNickList.indexOf(b.toUpperCase());
- if (index != -1) CTS.TempIgnoreNickList.splice(index, 1);
- } else {
- index = CTS.TempIgnoreUserList.indexOf(b.toUpperCase());
- if (index != -1) CTS.TempIgnoreUserList.splice(index, 1);
- }
- var e = new window.TinychatApp.BLL.IgnorelistUpdateUserEvent(a);
- this.EventBus.broadcast(window.TinychatApp.BLL.IgnorelistUpdateUserEvent.ID, e);
- this.app.showToast(a.username + " unignored");
- };
- if (CTS.StorageSupport) {
- window.TinychatApp.BLL.SettingsFeature.prototype.getSettings = function() {
- var A = this._get("tinychat_settings");
- try {
- A = Object.assign(new window.TinychatApp.DAL.SettingsEntity(), JSON.parse(A));
- } catch (E) {}
- if (A !== undefined) {
- CTS.enableSound = A.enableSound;
- if (CTS.enablePMs !== A.enablePMs) {
- CTS.enablePMs = A.enablePMs;
- PMShow();
- }
- }
- return ((void 0 == A || "object" !== typeof A) && (A = new window.TinychatApp.DAL.SettingsEntity()) || A);
- };
- }
- if (!CTS.Project.isTouchScreen) {
- window.TinychatApp.BLL.ChatRoom.prototype.prepareStream = function(a) {
- function b() {
- if (null == c.mediaStreamCanvas) {
- if (CTS.AnimationFrameWorker != undefined) {
- CTS.AnimationFrameWorker.terminate();
- CTS.AnimationFrameWorker = undefined;
- }
- CTS.Me.broadcasting = false;
- return;
- }
- d.clearRect(0, 0, c.mediaStreamCanvas.width, c.mediaStreamCanvas.height);
- var a = c.mediaStreamVideo.videoHeight,
- e = c.mediaStreamVideo.videoWidth;
- c.mediaStreamCanvas.width = e;
- c.mediaStreamCanvas.height = a;
- window.TinychatApp.BLL.VideoFilters.getFilter(CTS.MediaStreamFilter).apply(d, e, a);
- d.drawImage(c.mediaStreamVideo, 0, 0, e, a, 0, 0, c.mediaStreamCanvas.width, c.mediaStreamCanvas.height);
- }
- this.mediaStreamOrigin = a;
- this.mediaStreamVideo = document.createElement("video");
- this.mediaStreamVideo.srcObject = this.mediaStreamOrigin;
- this.mediaStreamVideo.pause();
- this.mediaStreamVideo.oncanplay = function() {
- CTS.Me.broadcasting = true;
- if (CTS.WorkersAllowed) {
- if (CTS.AnimationFrameWorker == undefined) {
- CTS.AnimationFrameWorker = new Worker(window.URL.createObjectURL(new Blob(["function Counter() {self.postMessage(\"0\");}setInterval(function(){Counter();}, 1e3/" + CTS.FPS + ");"])));
- CTS.AnimationFrameWorker.onmessage = function() {
- b();
- };
- }
- } else {
- requestAnimationFrame(b);
- }
- };
- this.mediaStreamVideo.autoplay = !0;
- this.mediaStreamVideo.muted = !0;
- this.mediaStreamCanvas = document.createElement("canvas");
- var c = this,
- d = this.mediaStreamCanvas.getContext("2d");
- this.mediaStreamVideo.play();
- var e = this.mediaStreamCanvas.captureStream(CTS.FPS);
- return (e.addTrack(this.mediaStreamOrigin.getAudioTracks()[0]) || e);
- {
- function RTC() {
- if (null != arguments[0].rtc) {
- let a = arguments[0].rtc;
- arguments[0].rtc = null;
- MS(arguments[0], a);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement