Add copy comment link on hold button, pause video if visiting comments
This commit is contained in:
parent
3b98b5ea06
commit
3d806c729c
|
|
@ -199,7 +199,7 @@
|
|||
</div>
|
||||
{% endif %}
|
||||
<span class="button-wrapper">
|
||||
<button type="button" onclick='comments("{{ post.permalink }}")'>Comments</button>
|
||||
<button type="button" onpointerdown='commentsDown(this, "{{ post.permalink }}")' onpointerup='commentsUp(this, "{{ post.permalink }}")'>Comments</button>
|
||||
<button type="button" onclick='hide(this, "{{ post.permalink }}")'>Hide</button>
|
||||
</span>
|
||||
</div>
|
||||
|
|
@ -285,10 +285,28 @@
|
|||
}
|
||||
}
|
||||
|
||||
function comments(permalink){
|
||||
window.open("https://reddit.com" + permalink, '_blank');
|
||||
commentTimer = null;
|
||||
|
||||
function commentsDown(button, permalink) {
|
||||
commentTimer = setTimeout(() => {
|
||||
navigator.clipboard.writeText("https://reddit.com" + permalink);
|
||||
commentTimer = null;
|
||||
button.textContent = "Copied!"
|
||||
}, 500);
|
||||
}
|
||||
|
||||
function commentsUp(button, permalink) {
|
||||
if (commentTimer != null) {
|
||||
clearTimeout(commentTimer);
|
||||
commentTimer = null;
|
||||
pauseVideo(button);
|
||||
window.open("https://reddit.com" + permalink, '_blank');
|
||||
} else {
|
||||
setTimeout(() => {
|
||||
button.textContent = "Comments";
|
||||
}, 500);
|
||||
}
|
||||
}
|
||||
// text expand code
|
||||
|
||||
function checkHeight(){
|
||||
|
|
@ -316,9 +334,17 @@
|
|||
});
|
||||
|
||||
// audio/video sync code
|
||||
function pauseVideo(element){
|
||||
div = element.closest('.post');
|
||||
video = div.querySelector('video:first-of-type');
|
||||
if (video) {
|
||||
video.pause();
|
||||
pauseAudio(video);
|
||||
}
|
||||
}
|
||||
|
||||
function findAudio(video){
|
||||
const div = video.closest('.post');
|
||||
div = video.closest('.post');
|
||||
return div.querySelector('audio:first-of-type');
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue