#2023/01 #代码块 v2ex 分屏浏览,打开主页,f12控制台运行
var iframeobj = document.createElement('iframe');
iframeobj.name = 'iframe_splitview';
iframeobj.style.zIndex = 999;
iframeobj.style.left = '50%';
iframeobj.style.top = 0;
iframeobj.style.width = '50%';
iframeobj.style.height = '100%';
iframeobj.style.position = 'fixed';
document.body.style.marginRight = '50%';
document.body.appendChild(iframeobj);
document.querySelectorAll('a').forEach(function(r_node) {
r_node.target = "iframe_splitview";
});
油猴插件
// ==UserScript==
// @name V2EX 优化
// @namespace https://www.v2ex.com/
// @version 0.1
// @description 分屏 v2ex!
// @author You
// @match https://v2ex.com/
// @match https://www.v2ex.com/
// @match https://www.v2ex.com/recent?p=*
// @match https://v2ex.com/t/*
// @match https://www.v2ex.com/t/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=v2ex.com
// @grant none
// @run-at document-end
// ==/UserScript==
(function () {
"use strict";
let url = window.location.href;
let is_index = url.indexOf("/t/") === -1;
if (is_index) {
if (window.self === window.top) {
document.write(
`
<html>
<head>
<script>
var iframe_open_url = function (url) {
document.getElementById('iframe_splitview').src = url;
let current_url = window.location.href;
history.replaceState({},"",url);
history.replaceState({},"",current_url);
}
</script>
</head>
<frameset cols='50%, 50%'>
<frame src='${location.href}'>
<frame src='' id='iframe_splitview'>
</frameset >
</html>
`
);
} else {
document.body.style.minWidth = "unset";
let nodes = document.querySelectorAll(".item_title");
for (let i = 0; i < nodes.length; i++) {
nodes[i].addEventListener("click", function (e) {
e.preventDefault();
let url = nodes[i].getElementsByClassName("topic-link")[0].href;
window.parent.iframe_open_url(url);
});
}
}
} else {
if (window.self !== window.top) {
document.body.style.minWidth = "unset";
}
}
})();