YGestures

for Android Browser without Touch Gestures(particularly Yandex)【向手机版yandex浏览器注入前进&后退手势&&网页文本粘贴功能,并可临时禁用某一手势】

  1. // ==UserScript==
  2. // @name YGestures
  3. // @namespace http://monodog.net/
  4. // @version 0.6.1
  5. // @license CC-BY-NC-SA-4.0
  6. // @description for Android Browser without Touch Gestures(particularly Yandex)【向手机版yandex浏览器注入前进&后退手势&&网页文本粘贴功能,并可临时禁用某一手势】
  7. // @author Monodog Theiions
  8. // @icon https://monodog.neocities.org/js/icon/YGestures.png
  9. // @homepage https://gf.qytechs.cn/zh-CN/scripts/392713-ygestures
  10. // @supportURL mailto:wung.thy@gmail.com
  11. // @match http://*/*
  12. // @include https://*/*
  13. // @exclude *://*login*
  14. // @run-at document-body
  15. // @require https://cdn.jsdelivr.net/npm/hammerjs@2.0.8
  16. // @grant unsafeWindow
  17. // @contributionURL https://qr.alipay.com/fkx02998fhy75rwy0pjx2eb
  18. // @compatible Yandex for Android , etc
  19. // @incompatible All Browser without Touch
  20. // ==/UserScript==
  21.  
  22. (function() {
  23. 'use strict';
  24. let YGScript ;
  25. let head=document.getElementsByTagName("head")[0];
  26. function WriteJsFunction(cont,html) {
  27. cont.innerHTML ="<div>js...</div>"+html;
  28. let oldScript = cont.getElementsByTagName('script')[0];
  29. let newScript = document.createElement('script');
  30. newScript.type = 'text/javascript';
  31. newScript.innerHTML = oldScript.innerHTML;
  32. head.appendChild(newScript);
  33. head.removeChild(YGScript);
  34. YGScript=newScript;
  35. }
  36.  
  37.  
  38. if(window.navigator.userAgent.toLowerCase().indexOf("linux")>10)// code here
  39. {
  40. let YGBool=0;
  41. let allowNone="none";
  42. let copyStr="";
  43. let array=["上隐藏*下显示*左前进*右后退,按住禁用滑动事件","右滑已经禁用,按住继续更改","水平滑动已经禁用,按住继续更改","上下功能已对调,左右滑动已禁用,按住还原"];
  44. let body=document.getElementsByTagName("body")[0];
  45. var floatDIV = document.createElement("div");
  46. YGScript = document.createElement("script");
  47. head.appendChild(YGScript);
  48. floatDIV.style.cssText=
  49. "z-index: 9999;width:100%; height:30px; background:SlateBlue;color:Ivory;line-height:30px;display:none;position: fixed;bottom: 0;font-size:12px";
  50. floatDIV.innerHTML=array[0];
  51. body.appendChild(floatDIV);
  52. let footArea = document.createElement("textarea");
  53. footArea.rows="9";footArea.style.cssText=
  54. "z-index: 9999;width:60%;border:solid 1px #f00; background:Ivory;color:SlateBlue;display:none;position: fixed;bottom: 30px;font-size:12px";
  55. body.appendChild(footArea);
  56. let pingGoogle=false;
  57. let imgStic=document.createElement("img");
  58. imgStic.src="https://about.google/assets/img/menu.png?cache="+parseInt(new Date().getTime()/9999);
  59. imgStic.onload = function() {
  60. pingGoogle=true;
  61. body.removeChild(imgStic);
  62. }
  63. body.appendChild(imgStic);
  64. new Hammer(body).on("pan", function(e) {
  65. let _e = event || window.event;
  66. if(Math.abs(e.deltaY) < 2 * Math.abs(e.deltaX) + 2 ) {
  67. if(Math.abs(e.deltaX)< 2 * Math.abs(e.deltaY)+ 2 && Math.abs(e.deltaX)>2 ) {
  68. if(e.deltaX>0){
  69. //let e = event || window.event;
  70. copyStr=(document.elementFromPoint(_e.clientX, _e.clientY).innerHTML);
  71. floatDIV.style.display="block";
  72. if(footArea.style.display=="none")floatDIV.innerHTML=array[YGBool]+"#@向上拖拽启动粘贴";
  73. copyStr=copyStr.replace(/<[^>]*>/g, '\r\n');footArea.value=copyStr;
  74. }
  75. else if(e.deltaY>2){
  76. if(footArea.value==""||footArea.style.display=="none"){
  77. //alert(e.deltaX+';'+e.deltaY);
  78. YGBool=0;
  79. floatDIV.innerHTML=array[YGBool];
  80. floatDIV.style.display=allowNone;
  81. ;footArea.style.display="none";
  82. copyStr="";
  83. }
  84. else if(footArea.value.substr(0,4)=="http"){
  85. window.open(footArea.value);
  86. }
  87. else{
  88. if(copyStr!="<"+footArea.value+">"){
  89. copyStr=footArea.value;
  90. if(!pingGoogle) window.open("https://www.baidu.com/s?wd="+copyStr);
  91. else window.open("https://www.google.com/search?ie=UTF-8&q="+copyStr);
  92. copyStr="<"+footArea.value+">";
  93. }
  94. }
  95. }
  96. else{
  97. "unsafe#cannot use";
  98. }
  99. }
  100. }
  101. else if(((e.deltaY<0)!=(YGBool==3))&&footArea.style.display=="none") {floatDIV.style.display=allowNone;}
  102. else floatDIV.style.display= "block";})
  103. .on("swipeleft", function (e) {
  104. if(Math.abs(e.deltaX) > 2 * Math.abs(e.deltaY) + 2 && YGBool<2 ) window.history.go(1);})
  105. .on("swiperight", function (e) {
  106. if(Math.abs(e.deltaX) > 2 * Math.abs(e.deltaY) + 2 && YGBool==0 ) window.history.go(-1);})
  107. .on("pressup", function (x) { var e = event || window.event;
  108. let ele=document.elementFromPoint(e.clientX,e.clientY);
  109. if(ele!=footArea&&ele!=floatDIV) {copyStr=ele.innerHTML;
  110. floatDIV.style.display="block";}
  111. if(footArea.style.display=="none")floatDIV.innerHTML=array[YGBool]+"#@向上拖拽启动粘贴";
  112. copyStr=copyStr.replace(/<[^>]*>/g, '\r\n');footArea.value=copyStr;})
  113.  
  114.  
  115.  
  116. new Hammer(floatDIV).on("pressup", function (e) {
  117. if(footArea.style.display=="block");
  118. else if(copyStr=="") floatDIV.innerHTML=array[YGBool=(YGBool+1)&3];
  119. else floatDIV.innerHTML=array[YGBool=(YGBool+1)&3]+"#@向上拖拽启动粘贴";})
  120. .on("pan", function (e) {
  121. if(-(e.deltaY) > 2 * Math.abs(e.deltaX) + 2 ) {
  122. let fv=footArea.value;
  123. if(footArea.style.display=="block"&&
  124. fv.substr(0,8)=="<script>"&&fv.substr(-9)=='</script>'){
  125. WriteJsFunction(floatDIV,"<script>\nfunction YG_Script(){\n"+fv.slice(8,-9)+";\nreturn 'true';\n}\n<\/script>");
  126. copyStr=""+YG_Script();
  127. }
  128. footArea.style.display=(copyStr!=""||YGBool<2)?"block":"none";
  129. floatDIV.style.display="block";
  130. YGBool=2;
  131. footArea.value=(copyStr=="")?body.innerHTML:copyStr;
  132. floatDIV.innerHTML=footArea.style.display!="none"?"左滑收起,左滑转上滑安全收起;":array[YGBool];
  133.  
  134. //footArea.value=document.getElementsByTagName("head")[0].innerHTML;
  135. }
  136. if(Math.abs(e.deltaX) > 2 * Math.abs(e.deltaY) + 2 ) {
  137. if(e.deltaX<0) {
  138. if(YGBool!=3&&footArea.style.display=="none"){
  139. window.opener=null;
  140. window.open('','_self');
  141. window.close();}
  142. footArea.style.display="none";
  143. YGBool=3;copyStr="";
  144. floatDIV.innerHTML=array[YGBool];}
  145. else if(footArea.style.display=="none") {allowNone="block";floatDIV.innerHTML="控制模块已锁定";}
  146. else if(footArea.value.substr(0,4)=="http"){
  147. window.open(footArea.value);
  148. }
  149. else{
  150. if(copyStr!="<"+footArea.value+">"){
  151. copyStr=footArea.value;
  152. if(!pingGoogle) window.open("https://www.baidu.com/s?wd="+copyStr);
  153. else window.open("https://www.google.com/search?ie=UTF-8&q="+copyStr);
  154. copyStr="<"+footArea.value+">";
  155. }
  156. }
  157. }
  158.  
  159. })
  160. }
  161. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址