This commit is contained in:
Lorenz Hübschle-Schneider 2023-07-09 14:13:35 +02:00
parent 5e47768135
commit 147028f1a5
3 changed files with 26 additions and 25 deletions

View File

@ -131,7 +131,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
// Show a TLS warning if GB was loaded over an unencrypted connection, // Show a TLS warning if GB was loaded over an unencrypted connection,
// except for local instances (local files, testing) // except for local instances (local files, testing)
$scope.show_tls_warning = (["https:", "file:"].indexOf(window.location.protocol) === -1) && $scope.show_tls_warning = (["https:", "file:"].indexOf(window.location.protocol) === -1) &&
(["localhost", "127.0.0.1", "::1"].indexOf(window.location.hostname) === -1) (["localhost", "127.0.0.1", "::1"].indexOf(window.location.hostname) === -1);
$rootScope.isWindowFocused = function() { $rootScope.isWindowFocused = function() {
if (typeof $scope.documentHidden === "undefined") { if (typeof $scope.documentHidden === "undefined") {

View File

@ -239,34 +239,35 @@ plugins.factory('userPlugins', function() {
var twitchPlugin = new UrlPlugin('Twitch video', function(url) { var twitchPlugin = new UrlPlugin('Twitch video', function(url) {
var regex = /(?:https?:\/\/)?clips\.twitch\.tv\/([^\?\&\/\s]+)/i, var regex = /(?:https?:\/\/)?clips\.twitch\.tv\/([^\?\&\/\s]+)/i,
match = url.match(regex); match = url.match(regex),
embedurl,
element;
if (match){ if (match) {
var clipId = match[1]; var clipId = match[1];
var embedurl = "https://clips.twitch.tv/embed?clip=" + clipId + "&parent=" + window.location.hostname; embedurl = "https://clips.twitch.tv/embed?clip=" + clipId + "&parent=" + window.location.hostname;
element = angular.element('<iframe></iframe>')
var element = angular.element('<iframe></iframe>') .attr('src', embedurl)
.attr('src', embedurl) .attr('width', '560')
.attr('width', '560') .attr('height', '315')
.attr('height', '315') .attr('allowfullscreen', 'true');
.attr('allowfullscreen', 'true');
return element.prop('outerHTML'); return element.prop('outerHTML');
} }
var regex = /(?:https?:(?:\/\/www\.)?)?twitch\.tv\/(?:videos\/(\d+)|(\w+))/i, regex = /(?:https?:(?:\/\/www\.)?)?twitch\.tv\/(?:videos\/(\d+)|(\w+))/i;
match = url.match(regex); match = url.match(regex);
if (match) { if (match) {
var mediaType = "video"; var mediaType = "video";
if(match[1] === undefined) { if (match[1] === undefined) {
mediaType = "channel"; mediaType = "channel";
} }
var mediaId = match[1] === undefined ? match[2] : match[1]; var mediaId = match[1] === undefined ? match[2] : match[1];
var embedurl = "https://player.twitch.tv/?" + mediaType + "=" + mediaId + "&parent=" + window.location.hostname + "&autoplay=false&muted=true"; embedurl = "https://player.twitch.tv/?" + mediaType + "=" + mediaId + "&parent=" + window.location.hostname + "&autoplay=false&muted=true";
var element = angular.element('<iframe></iframe>') element = angular.element('<iframe></iframe>')
.attr('src', embedurl) .attr('src', embedurl)
.attr('width', '560') .attr('width', '560')
.attr('height', '315') .attr('height', '315')
.attr('allowfullscreen', 'true'); .attr('allowfullscreen', 'true');
return element.prop('outerHTML'); return element.prop('outerHTML');
} }
}); });

View File

@ -27,7 +27,7 @@ weechat.factory('utils', function() {
const _isTauri = window.__TAURI__ !== undefined; const _isTauri = window.__TAURI__ !== undefined;
var isTauri = function() { var isTauri = function() {
return _isTauri; return _isTauri;
} };
// Inject a javascript (used by KaTeX) // Inject a javascript (used by KaTeX)
var inject_script = function(script_url) { var inject_script = function(script_url) {