Option to rewrite all Twitter links to Nitter,click on animated GIF works like image now,full height for images option now works for animated GIF

This commit is contained in:
nipos 2019-09-21 17:13:45 +02:00
parent 660e6c46e6
commit d120e6438c
12 changed files with 110 additions and 8 deletions

View File

@ -28,6 +28,7 @@ We moved our instances list to our webpage: https://www.halcyon.social/instances
or read our new documentation pages to install it manually: https://www.halcyon.social/documentation.php?page=install
## Blog
- Release of Version 2.4.4 - Option to rewrite all Twitter links to Nitter,click on animated GIF works like image now,full height for images option now works for animated GIF
- Release of Version 2.4.3 - Fixed login,fixed YouPlay/Invidious embeds,fixed empty image placeholder when audio available,improved status template code
- Release of Version 2.4.2 - Many bugfixes,add trending hashtags,add URL unshortener,redirect YouTube to Invidious,translation improvements,add Spanish translation
- Release of Version 2.4.1 - Improve French and German translation,respect Pleromas/GlitchSocs custom poll limits,add extension download link,many bugfixes

View File

@ -81,6 +81,8 @@ const ytcom = $(this).attr('href').match(/https?:\/\/(www\.)?youtube\.com\/watch
if(ytcom) $(this).attr('target','_self').attr('href',"javascript:openVideo('"+ytcom[2]+"');void(0)");
const ytbe = $(this).attr('href').match(/https?:\/\/(www\.)?youtu\.be\/([a-zA-Z\d_-]+)/);
if(ytbe) $(this).attr('target','_self').attr('href',"javascript:openVideo('"+ytbe[2]+"');void(0)");
const twcom = $(this).attr('href').match(/https?:\/\/(www\.)?twitter\.com\/(.*)/);
if(twcom) $(this).attr('target','_self').attr('href',"javascript:openNitter('"+twcom[2]+"');void(0)");
if(server_setting_unshorten && checkURLshortener($(this).attr('href'))) {
var linkrand = Math.round(Math.random()*1000000);
$(this).attr("data-random",linkrand);
@ -475,6 +477,17 @@ $('.overlay_redirect_invidious').data("video",video);
$('.overlay_redirect_invidious').removeClass('invisible');
}
}
function openNitter(path) {
if(localStorage.setting_redirect_nitter == "true") window.open("https://"+server_setting_nitter+"/"+path,"_blank");
else if(localStorage.setting_redirect_nitter == "false") window.open("https://twitter.com/"+path,"_blank");
else {
$("#js-overlay_content_wrap .temporary_object").empty();
$('#js-overlay_content_wrap').addClass('view');
$('#js-overlay_content_wrap').addClass('black_08');
$('.overlay_redirect_nitter').data("path",path);
$('.overlay_redirect_nitter').removeClass('invisible');
}
}
function checkStatusLinks(text) {
$("<span>"+text+"</span>").find("a").each(function(i) {
const ytcom = $(this).attr('href').match(/https?:\/\/(www\.)?youtube\.com\/watch\?v=([a-zA-Z\d_-]+)/);

View File

@ -449,6 +449,12 @@ $("#setting_redirect_invidious")[0].checked = true;
if(localStorage.setting_redirect_invidious != "unset") {
$("#setting_redirect_invidious_reset").show();
}
if(localStorage.setting_redirect_nitter == "true") {
$("#setting_redirect_nitter")[0].checked = true;
}
if(localStorage.setting_redirect_nitter != "unset") {
$("#setting_redirect_nitter_reset").show();
}
});
$("#setting_play_gif").change(function() {
if(this.checked) {
@ -537,6 +543,23 @@ $("#setting_redirect_invidious_reset").fadeOut();
$("#setting_redirect_invidious")[0].checked = false;
putMessage(__("Youtube link redirect reset to default"));
});
$("#setting_redirect_nitter").change(function() {
$("#setting_redirect_nitter_reset").fadeIn();
if(this.checked) {
localStorage.setItem("setting_redirect_nitter","true");
putMessage(__("Twitter links redirected to Nitter"));
}
else {
localStorage.setItem("setting_redirect_nitter","false");
putMessage(__("Twitter links not redirected anymore"));
}
});
$("#setting_redirect_nitter_reset").click(function() {
localStorage.setItem("setting_redirect_nitter","unset");
$("#setting_redirect_nitter_reset").fadeOut();
$("#setting_redirect_nitter")[0].checked = false;
putMessage(__("Twitter link redirect reset to default"));
});
}
else if(window.location.pathname == "/settings/blocks") {
$('#js-settings_nav_blocks').toggleClass('view');

View File

@ -36,7 +36,7 @@ else if(status.media_attachments[i].type === "gifv") {
var vidprev = "";
if(status.media_attachments[i].preview_url != status.media_attachments[i].url) vidprev = "<img src='"+status.media_attachments[i].preview_url+"'>";
media_embeds.push(`
<div class="media_attachment" otype="video/gifv" mediacount="${i}">
<div class="media_attachment with_overlay" otype="video" sid="${status.id}" oid="${status.media_attachments[i].id}" url="${status.media_attachments[i].url}" mediacount="${i}">
<video frameborder="0" title="${status.media_attachments[i].description}" autoplay loop muted>
<source src="${status.media_attachments[i].url}">
${vidprev}
@ -56,7 +56,7 @@ audio_embeds.push(audio_embed);
}
else if(status.media_attachments[i].type === "image") {
media_embeds.push(`
<div class="media_attachment" otype="image" sid="${status.id}" oid="${status.media_attachments[i].id}" url="${status.media_attachments[i].url}" mediacount="${i}">
<div class="media_attachment with_overlay" otype="image" sid="${status.id}" oid="${status.media_attachments[i].id}" url="${status.media_attachments[i].url}" mediacount="${i}">
<img src="${status.media_attachments[i].url}" title="${status.media_attachments[i].description}" window_view="enable"/>
<div class='sensitive_alert'${blurbackground}>
<span class="text1">${__('Sensitive content')}</span>
@ -66,7 +66,7 @@ media_embeds.push(`
}
}
if(status.media_attachments[0].type === "video" && localStorage.setting_play_video != "false" && dsplength == 1) border = ' style="border:0;border-radius:0"';
if(localStorage.setting_full_height == "true" && status.media_attachments.length == 1 && (status.media_attachments[0].type == "image" || (status.media_attachments[0].type === "video" && localStorage.setting_play_video == "false") || (status.media_attachments[0].type === "gifv" && localStorage.setting_play_gif == "false")))
if(localStorage.setting_full_height == "true" && status.media_attachments.length == 1 && (status.media_attachments[0].type == "image" || (status.media_attachments[0].type === "video" && localStorage.setting_play_video == "false") || status.media_attachments[0].type === "gifv"))
mvfullheight = " media_full_height";
if(media_embeds.length > 0) {
media_views = `<div class='media_views${mvfullheight}' sid="${status.id}" media_length='${dsplength}'${border}>`;
@ -666,7 +666,8 @@ var hidebackward = "";
var hideforward ="";
for(var i=0;i<status.media_attachments.length;i++) {
if(status.media_attachments[i].remote_url != null) status.media_attachments[i].url = status.media_attachments[i].remote_url;
if(status.media_attachments[i].type == "image") pictures.push(status.media_attachments[i].url);
if(status.media_attachments[i].description == null) status.media_attachments[i].description = "";
if(status.media_attachments[i].type == "image" || status.media_attachments[i].type == "gifv") pictures.push(status.media_attachments[i].url);
}
console.log(media);
console.log(parseInt(media));
@ -674,11 +675,20 @@ var mediacnt = pictures.indexOf(pictures.find(function(data) {if(data==this) ret
console.log(mediacnt);
if(mediacnt == 0) hidebackward = " style='display:none'";
if(mediacnt == pictures.length-1) hideforward = " style='display:none'";
if(status.media_attachments[media].type == "image") var player = `<img src="${status.media_attachments[media].url}" title="${status.media_attachments[media].description}">`;
else if(status.media_attachments[media].type == "gifv") {
var vidprev = "";
if(status.media_attachments[media].preview_url != status.media_attachments[media].url) vidprev = "<img src='"+status.media_attachments[media].preview_url+"'>";
var player = (`<video frameborder="0" title="${status.media_attachments[media].description}" autoplay loop muted style="width:100%">
<source src="${status.media_attachments[media].url}">
${vidprev}
</video>`);
}
const status_template = timeline_template(status).html(),
html = (`<div class="media_detail" pictures='${JSON.stringify(pictures)}' cid="${mediacnt}">
<div class="media_box">
<span class="media_backward"${hidebackward}><i class="fa fa-2x fa-chevron-left"></i></span>
<img src="${status.media_attachments[media].url}">
${player}
<span class="media_forward"${hideforward}><i class="fa fa-2x fa-chevron-right"></i></span>
</div>
<div class="toot_entry" sid="${status.id}">

View File

@ -1214,7 +1214,7 @@ replace_emoji();
});
}
$(function() {
$(document).on('click','.media_attachment[otype="image"]', function(e) {
$(document).on('click','.media_attachment.with_overlay', function(e) {
e.stopPropagation();
setOverlayMedia($(this).attr('sid'),$(this).attr('mediacount'));
$('.media_detail .toot_entry .media_views').addClass('invisible');
@ -2054,6 +2054,16 @@ $('.close_button').click();
window.open("https://www.youtube.com/watch?v="+$(".overlay_redirect_invidious").data("video"),"_blank");
if($("#redirect_invidious_permanent")[0].checked) localStorage.setting_redirect_invidious = "false";
});
$('.overlay_redirect_nitter_yes').click(function() {
$('.close_button').click();
window.open("https://"+server_setting_nitter+"/"+$(".overlay_redirect_nitter").data("path"),"_blank");
if($("#redirect_nitter_permanent")[0].checked) localStorage.setting_redirect_nitter = "true";
});
$('.overlay_redirect_nitter_no').click(function() {
$('.close_button').click();
window.open("https://twitter.com/"+$(".overlay_redirect_nitter").data("path"),"_blank");
if($("#redirect_nitter_permanent")[0].checked) localStorage.setting_redirect_nitter = "false";
});
if($("#js-overlay_content_wrap").hasClass("view")) $(document.body).css("overflow-y","hidden");
$("#js-overlay_content_wrap").attrchange(function(attr) {
if(attr == "class" && $("#js-overlay_content_wrap").hasClass("view")) $(document.body).css("overflow-y","hidden");
@ -2099,8 +2109,10 @@ $(document).on('click','.link_preview',function(e) {
e.stopPropagation();
const ytcom = $(this).data("url").match(/https?:\/\/(www\.)?youtube\.com\/watch\?v=([a-zA-Z\d_-]+)/);
const ytbe = $(this).data("url").match(/https?:\/\/(www\.)?youtu\.be\/([a-zA-Z\d_-]+)/);
const twcom = $(this).data("url").match(/https?:\/\/(www\.)?twitter\.com\/(.*)/);
if(ytcom) openVideo(ytcom[2]);
else if(ytbe) openVideo(ytbe[2]);
else if(twcom) openNitter(twcom[2]);
else window.open($(this).data("url"),"_blank");
});
$(document).on('focus','.status_textarea textarea,.status_top .status_spoiler',function(e) {

View File

@ -12,10 +12,12 @@ url_unshortener = true
; YouPlay resolves YouTube MP4s on your server and sends this link to the user for privacy-friendly watching
; Vimeo embeds work in the same way as YouPlay embeds here because the official players contain too much spyware
; Invidous is a external service to watch YouTube videos in a privacy-friendly way - Halcyon can automatically rewrite links to a instance you can set here
; Nitter is a external service to view Twitter contents in a privacy-friendly way - Halcyon can automatically rewrite links to a instance you can set here
[Media]
youplay = true
vimeo = true
invidious = invidiou.sh
nitter = nitter.nixnet.xyz
; The proxy can be used optionally to resolve data for privacy-friendly media embeds on the server side - It is not used for Mastodon API requests on login
; Proxy type can be set to none, socks5, socks4, http or https - Example settings for locally installed Tor client

View File

@ -16,6 +16,7 @@ include dirname(__FILE__).('/widgets/overlay_confirm.php');
include dirname(__FILE__).('/widgets/overlay_prompt.php');
include dirname(__FILE__).('/widgets/overlay_addlist.php');
include dirname(__FILE__).('/widgets/overlay_redirect_invidious.php');
include dirname(__FILE__).('/widgets/overlay_redirect_nitter.php');
if($_SERVER["REQUEST_URI"] == "/settings/filters") include dirname(__FILE__).('/widgets/overlay_filter.php');
?>
</div>

View File

@ -75,6 +75,7 @@ server_setting_youplay = <?=$config["Media"]["youplay"] ? "true" : "false"?>;
server_setting_vimeo = <?=$config["Media"]["vimeo"] ? "true" : "false"?>;
server_setting_unshorten = <?=$config["App"]["url_unshortener"] ? "true" : "false"?>;
server_setting_invidious = <?=$config["Media"]["invidious"] ? "'".$config["Media"]["invidious"]."'" : "'invidiou.sh'"?>;
server_setting_nitter = <?=$config["Media"]["nitter"] ? "'".$config["Media"]["nitter"]."'" : "'nitter.nixnet.xyz'"?>;
</script>
</head>
<body>

View File

@ -58,6 +58,7 @@ localStorage.setItem('setting_play_vimeo','false');
localStorage.setItem('setting_post_privacy','".$profile["source"]["privacy"]."');
localStorage.setItem('setting_post_sensitive','".$profile["source"]["sensitive"]."');
localStorage.setItem('setting_redirect_invidious','unset');
localStorage.setItem('setting_redirect_nitter','unset');
$.cookie('darktheme','unset',{path:'/',expires:3650});
if(sessionStorage.return && sessionStorage.return == 'share') location.href = '/intent/toot?action=send';
else location.href = '/';

View File

@ -99,7 +99,7 @@
</div>
<div class="redirect_invidious_wrap" style="float:left;width:50%">
<div class="switch" style="float:left">
<input type="checkbox" id="setting_redirect_invidious" >
<input type="checkbox" id="setting_redirect_invidious">
<div class="switch-btn">
<span></span>
</div>
@ -108,6 +108,20 @@
<i class="fa fa-2x fa-times" style="margin-top:8px"></i>
</a>
</div>
<div style="float:left;width:50%;text-align:right;margin-top:16px">
<h3><?=_('Redirect Twitter to Nitter')?></h3>
</div>
<div class="redirect_nitter_wrap" style="float:left;width:50%">
<div class="switch" style="float:left">
<input type="checkbox" id="setting_redirect_nitter">
<div class="switch-btn">
<span></span>
</div>
</div>
<a href="javascript:void(0)" id="setting_redirect_nitter_reset" style="float:left;display:none">
<i class="fa fa-2x fa-times" style="margin-top:8px"></i>
</a>
</div>
<span style="visibility:hidden">-</span>
</div>
</article>

View File

@ -1 +1 @@
2.4.3
2.4.4

View File

@ -0,0 +1,24 @@
<div class="overlay_simple overlay_redirect_nitter invisible">
<header class="overlay_simple_header">
<span><?=_('Protect your privacy!')?></span>
</header>
<div class="overlay_simple_body">
<div class="overlay_redirect_nitter_text" style="margin-bottom:10px">
<?=_("Halcyon has detected that you're trying to click a link to the centralized microblogging platform Twitter. Halcyon can automatically redirect that link to Nitter, a privacy-friendly and faster way to view this content for free and without any ads. Do you want to use Nitter?")?><br/>
<center><a href="https://github.com/zedeus/nitter" class="halcyon_link" target="_blank"><?=_("Tell me more about Nitter!")?></a></center>
<div style="margin-bottom:20px;width:100%">
<div class="switch" style="margin:0;float:left">
<input type="checkbox" id="redirect_nitter_permanent">
<div class="switch-btn">
<span></span>
</div>
</div>
<label for="redirect_nitter_permanent" style="margin-left:5px;vertical-align:sub"><?=_('Remember my decision')?></label>
</div>
</div>
<div class="overlay_simple_controls">
<button class="overlay_redirect_nitter_yes toot_button" style="float:right;width:150px"><div class="toot_button_label"><i class="fa fa-fw fa-check"></i><span><?=_('Open Nitter')?></span></div></button>
<a href="javascript:void(0)" class="overlay_redirect_nitter_no halcyon_link" style="float:right;margin-top:5px;margin-right:10px"><i class="fa fa-times"></i> <?=_('No, thanks')?></a>
</div>
</div>
</div>