tampermonkey-script/v2exMobile.user.js

48 lines
1.6 KiB
JavaScript
Raw Permalink Normal View History

2023-01-06 13:47:59 +00:00
// ==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);
}
})
})
}
})();