您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
在当前页面加载链接网页,左滑后退
当前为
// ==UserScript== // @name 在当前页面加载链接网页 // @description 在当前页面加载链接网页,左滑后退 // @include http://* // @include https://* // @author yechenyin // @version 0.3 // @namespace https://gf.qytechs.cn/users/3586-yechenyin // @grant GM_openInTab // ==/UserScript== $ = function(selector, attributes) { if (selector.indexOf('<') === 0 || attributes) { var element; if (selector.indexOf('<') === 0) element = document.createElement(selector.substring(1, selector.length - 1)); else element = document.createElement(selector); if (attributes) { for (var key in attributes) { element[key] = attributes[key]; } } return nodeToNodeList(element); } else { return document.querySelectorAll(selector); } }; function nodeToNodeList(node) { return Object.create(document.createDocumentFragment().childNodes, { length: { value: 1 }, 0: { value: node, enumerable: true }, }); } NodeList.prototype.forEach = Array.prototype.forEach; NodeList.prototype.click = function(func) { this.forEach(function(node) { node.onclick = func; }); }; NodeList.prototype.on = function(eventName, func) { for (var i = 0; i < this.length; i++) { this[i].addEventListener(eventName, func); } }; NodeList.prototype.append = function(element) { this.forEach(function(node) { for (var i = 0; i < element.length; i++) { node.appendChild(element[i]); } }); }; NodeList.prototype.appendTo = function(element) { if (typeof element == 'string') element = $(element); if (element instanceof NodeList) { this.forEach(function(node) { for (var i = 0; i < element.length; i++) { element[i].appendChild(node); } }); } }; NodeList.prototype.css = function(property, value) { this.forEach(function(node) { node.style[property] = value; }); }; NodeList.prototype.show = function() { this.css('display', 'block'); }; NodeList.prototype.last = function() { return nodeToNodeList(this[this.length - 1]); }; NodeList.prototype.remove = function(func) { if (this && this.length > 0) Array.prototype.forEach.call(this, function(node) { node.parentNode.removeChild(node); }); }; var load_process_bar; function open_tab(href) { if ($('.new_top_tab').length <= 10) { var tab = $('<iframe>', { src: href, className: 'new_top_tab', style: 'display:block; position:fixed; top:0; left:0; width:100%; height:100%; overflow:scroll; border: none; z-index: ' + String(2147483647 - 10 + $('.new_top_tab').length) }); $('body').append(tab); tab[0].onload = function() { this.style.display = 'block'; if (load_process_bar) clearInterval(load_process_bar); $('.tab_process_bar').remove(); console.log($('body')[0]); }; if (load_process_bar) clearInterval(load_process_bar); $('.tab_process_bar').remove(); $('<div>', { className: 'tab_process_bar', style: 'position:fixed; bottom:0; left:0; width:0; height:3px; border: none; background:#00ccff; z-index: 2147483647' }).appendTo('body'); var loaded = 0; var load_process_bar = setInterval(function() { loaded++; if (loaded <= 100) { $('.tab_process_bar').css('width', loaded + '%'); //var color = '000000' + Math.floor(parseInt('00ccff', 16) + (parseInt('9933ff', 16) - parseInt('00ccff', 16)) * loaded / 1000).toString(16); //$('.tab_process_bar').css('background', 'linear-gradient(to right, #00ccff, #' + color.substr(color.length - 6) + ')'); } else if ($('.tab_process_bar').length === 0) { clearInterval(load_process_bar); } }, 200); } else { window.open(href); } } function getAncestorLink(element) { while (element.nodeName != "A") { element = element.parentNode; } if (element.nodeName === "A" && element.href && element.href.indexOf('javascript') !== 0) return element; } document.addEventListener('click', function(e) { if (getAncestorLink(e.target)) { e.preventDefault(); e.stopPropagation(); if (window.self === window.top) { open_tab(e.target.href); } else { window.parent.postMessage(JSON.stringify({ href: e.target.href }), '*'); } } }); window.addEventListener('message', function(e) { console.log(e.data); if (e.data === 'go_back') { $('.tab_process_bar').remove(); $('.new_top_tab').last().remove(); } else if (e.data && 'href' in JSON.parse(e.data)) { open_tab(JSON.parse(e.data).href); } } ); var min_swipe_x = 50; var max_swipe_y = 30; var touch_start_x = 0; var touch_start_y = 0; var touch_move_x = 0; var touch_move_y = 0; document.addEventListener('touchstart', function(e) { touch_start_x = e.touches[0].clientX; touch_start_y = e.touches[0].clientY; }); document.addEventListener('touchmove', function(e) { //e.preventDefault(); touch_move_x = e.touches[0].clientX; touch_move_y = e.touches[0].clientY; console.log(touch_move_x - touch_start_x); if (touch_move_x - touch_start_x > 20 && touch_move_x - touch_start_x < 120 && $('.new_top_tab').length > 0 && window.self !== window.top) $('.new_top_tab').last().css('left', (touch_move_x - touch_start_x) + 'px'); }, { passive: true }); document.addEventListener('touchend', function(e) { console.log(touch_move_x - touch_start_x + ' ' + Math.abs(touch_move_y - touch_start_y)); if (touch_move_x - touch_start_x > min_swipe_x && Math.abs(touch_move_y - touch_start_y) < max_swipe_y) if (window.self !== window.top) { window.parent.postMessage('go_back', '*'); } else { history.go(-1); } });
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址