split view

originated from v2ex user @v2yllhwa

04.03.2023 itibariyledir. En son verisyonu görün.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

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.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name split view
// @namespace http://tampermonkey.net/
// @version 0.1
// @description originated from v2ex user @v2yllhwa
// @author You
// @match        https://*/*
// @match        http://*/*
// @match        ftp://*/*
// @grant none
// @run-at document-end
// @license MIT
// ==/UserScript==

(function () {
    "use strict";
    let url = window.location.href;
    if (window.self === window.top) {
        document.write(
`
<html>
<head>
</head>

<body style="margin:0;padding:0;background:gray;" scroll="no">
<iframe src='${url}' id='leftpage' style='width:49%;height:100%;float:left' frameborder='0' allowfullscreen='true' sandbox="allow-downloads allow-downloads-without-user-activation allow-presentation allow-modals allow-same-origin allow-scripts allow-popups allow-forms allow-pointer-lock allow-top-navigation-by-user-activation"></iframe>
<iframe src='' id='rightpage' style='width:49%;height:100%;float:right' frameborder='0' allowfullscreen='true' sandbox="allow-downloads allow-downloads-without-user-activation allow-presentation allow-modals allow-same-origin allow-scripts allow-popups allow-forms allow-pointer-lock allow-top-navigation-by-user-activation"></iframe>
</body>

<script>
var lefturl = '${url}';
var righturl;
var iframe_open_url = function (left, right) {
if(righturl != right){
righturl = right;
document.getElementById('rightpage').src = righturl;
}
if(lefturl != left){
lefturl = left;
document.getElementById('leftpage').src = lefturl;
}
history.replaceState({},"",righturl);
history.replaceState({},"",lefturl);
}
</script>
</html>
`
            );
        } else {
            document.body.style.minWidth = "unset";
            let nodes = document.querySelectorAll("a");
            for (let i = 0; i < nodes.length; i++) {
                // console.log(nodes[i].href);
                nodes[i].addEventListener("click", function (e) {
                    e.preventDefault();
                    e.stopPropagation();
                    window.parent.iframe_open_url(url, nodes[i].href);
                });
            }
        }
})();