From fcbf640922d7a1c4da62da7a7388bd855c50285c Mon Sep 17 00:00:00 2001 From: xing Date: Fri, 6 Jan 2023 21:47:59 +0800 Subject: [PATCH] =?UTF-8?q?v2ex=E8=BE=85=E5=8A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- v2exMobile.user.js | 48 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 v2exMobile.user.js diff --git a/v2exMobile.user.js b/v2exMobile.user.js new file mode 100644 index 0000000..fc98156 --- /dev/null +++ b/v2exMobile.user.js @@ -0,0 +1,48 @@ +// ==UserScript== +// @name v2ex h5 辅助脚本 +// @namespace http://tampermonkey.net/ +// @version 0.5 +// @homepage https://code.xloyy.com/xing/tampermonkey-script/ +// @description try to take over the world! +// @author xing +// @match https://v2ex.com/* +// @icon https://v2ex.com/static/favicon.ico +// @grant GM_addStyle +// @license MIT +// ==/UserScript== + + +(function () { + 'use strict'; + document.body.style.zoom = 1.25;//缩放1.25倍 + + //左滑后台新标签打开网页 右滑新标签打开网页 + slioV2ex(document.querySelectorAll('#Wrapper .content .cell.item'), '.item_title a') + + function slioV2ex(els, aquery) { + let startX = 0; + let endX = 0; + let startY = 0; + let endY = 0; + els.forEach(li => { + li.addEventListener('touchstart', e => { + startX = e.changedTouches[0].screenX; + startY = e.changedTouches[0].screenY; + }); + li.addEventListener('touchmove', e => { + endX = e.changedTouches[0].screenX; + endY = e.changedTouches[0].screenY; + }); + + li.addEventListener('touchend', evt => { + if ((endX - startX) > 100 && Math.abs(endY - startY) <= 100) { + let url = li.querySelector(aquery).href; + window.open(url, '_blank'); + } + if ((startX - endX) > 100 && Math.abs(endY - startY) <= 100) { + GM.openInTab(li.querySelector(aquery).href, true); + } + }) + }) + } +})(); \ No newline at end of file