Small improvements for users.
// ==UserScript==
// @name Endchan Plus
// @namespace https://greasyfork.org/en/scripts/380490-endchan-plus
// @version 0.3
// @description Small improvements for users.
// @author Doc
// @include https://endchan.xyz/*
// @match https://endchan.org/*/*
// @match https://endchan.net/*/*
// @match https://endchan.xyz/*/*
// @grant none
// ==/UserScript==
var old = '';
var preview = document.createElement('div');
preview.style = 'position:absolute;right:0px;';
var latch = false;
setInterval(function(){
if (JSON.stringify(selectedFiles) != old){
old = JSON.stringify(selectedFiles);
makethumbs();
};
if (latch){return};
if (document.querySelector('nav')){
document.querySelector('nav').appendChild(preview);
latch = true;
go();
}
}, 200);
function makethumbs(){
if (window.FileReader) {
preview.innerHTML = '';
for (var i = 0; i < selectedFiles.length; i++) {
var Reader = new FileReader();
var file = selectedFiles[i];
if (file.type.indexOf("video") > -1) {
Reader.onload = function (event) {
var t = document.createElement('video');
t.autoplay = true;
t.muted = true;
t.style = "max-height:150px;margin-left:2px;";
t.src = event.target.result;
preview.appendChild(t);
};
Reader.readAsDataURL(file);
} else {
Reader.onload = function (event) {
var t = document.createElement('img');
t.style = "max-height:150px;margin-left:2px;";
t.src = event.target.result;
preview.appendChild(t);
};
Reader.readAsDataURL(file);
};
}
} else {
alert('no filereader');
}
};
//nameLabel
function go(){
var hover = document.createElement('img');
var vhover = document.createElement('video');
vhover.autoplay = true;
vhover.muted = true;
document.body.appendChild(vhover);
document.body.appendChild(hover);
var s = 'position:fixed;max-height:90vh;top:0px;right:0px;pointer-events:none;';
hover.style = s;
vhover.style = s;
document.addEventListener('mouseover', function (e) {
if (e.target.nodeName == 'IMG') {
if (e.target.parentNode.className == 'imgLink' && e.target.className != 'imgExpanded') {
hover.src = e.target.parentNode.href;
};
if (e.target.src.indexOf('video') != -1) {
vhover.src = e.target.src.replace('t_', '') + '.' + e.target.src.split('video')[1]
}
} else {
hover.src = '';
vhover.src = '';
}
});
console.log('go');
//if (window.location.href.indexOf('rapport') != -1){document.querySelector('#fieldName').value = "Doc";document.querySelector('#qrname').value = "Doc"};
// document.querySelector('#qrbutton').addEventListener('click', function(){this.value = "Posting..."; setTimeout(() => this.value = "New Reply", 2000); })
// document.querySelector('#jsButton').addEventListener('click', function(){this.value = "Posting..."; setTimeout(() => this.value = "New Reply", 2000); })
};