Endchan Plus

Small improvements for users.

Version vom 21.03.2019. Aktuellste Version

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Endchan Plus
// @namespace    https://greasyfork.org/en/scripts/380490-endchan-plus
// @version      0.4
// @description  Small improvements for users.
// @author       Doc
// @include      https://endchan.xyz/*
// @match https://endchan.org/*/*
// @match https://endchan.net/*/*
// @match https://endchan.xyz/*/*
// @require      http://code.jquery.com/jquery-latest.js
// @grant        none
// @copyright 2019, drchloe2 (https://openuserjs.org//users/drchloe2)
// @license MIT
// ==/UserScript==


//NAME SAVER
var name = '';
if (localStorage.getItem("name")){
    name = localStorage.getItem("name")
} else {
    localStorage.setItem("name", "")
}

$(document).on('change', "#fieldName", function () {
    name = $(this).val();
    localStorage.setItem("name", name)
});

$('#fieldName').val(name);
$('#qrname').val(name);

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('#fieldName').name == "name"){
        document.querySelector('nav').appendChild(preview);
        latch = true;
        //go();
    }
}, 200);

setTimeout(function(){go();}, 5000)

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');
    }

};

//HOVER
var hover = document.createElement('img');
var vhover = document.createElement('video');
vhover.autoplay = true;
vhover.muted = true;
vhover.loop = true;
document.body.appendChild(vhover);
document.body.appendChild(hover);
var s = 'position:fixed;max-height:90vh;top:0px;right:0px;pointer-events:none;z-index:9999;';
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 = '';
    }
});


function go(){
    console.log('go');
    //POST WATCHER
    var targetNode = document.querySelector('.divPosts');
    var config = {childList : true};
    var newpost = function (mutationsList) {
        for (var mutation of mutationsList) {
            if (mutation.type == 'childList') {
                var mut = mutation.addedNodes[0].querySelector('.divMessage');
                mut.outerHTML = '<br>'+mut.outerHTML;
                console.log(mutation.addedNodes);
            }
        }
    };
    var observer = new MutationObserver(newpost);
    observer.observe(targetNode, config);
};