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,
// except for local instances (local files, testing)
$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() {
if (typeof $scope.documentHidden === "undefined") {

View File

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

View File

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