图寻-隐藏街景车和指南针

去除图寻街景车。使用Shift+K切换指南针。移植自GeoNoCar by 2020, drparse。参考了Tuxun Replayer, kakageo。

  1. // ==UserScript==
  2. // @name TuxunNoCar
  3. // @name:zh-CN 图寻-隐藏街景车和指南针
  4. // @description Redacts the car from tuxun, the Chinese geoguessr. Shift-K to toggle compass. Transplanted from GeoNoCar by 2020, drparse. Referenced kakageo's Tuxun Replayer plugin.
  5. // @description:zh-CN 去除图寻街景车。使用Shift+K切换指南针。移植自GeoNoCar by 2020, drparse。参考了Tuxun Replayer, kakageo。
  6. // @namespace https://tuxun.fun/
  7. // @version 0.1.8
  8. // @author strombooli
  9. // @match https://tuxun.fun/*
  10. // @match https://tuxun.fun/world-match
  11. // @match https://tuxun.fun/china-match
  12. // @match https://tuxun.fun/solo/*
  13. // @match https://tuxun.fun/map/*
  14. // @match https://tuxun.fun/party
  15. // @match https://tuxun.fun/party/*
  16. // @exclude https://tuxun.fun/challenge/*
  17. // @exclude https://tuxun.fun/replay-pano?*
  18. // @exclude https://tuxun.fun/wonders
  19. // @exclude https://tuxun.fun/random
  20. // @grant unsafeWindow
  21. // @run-at document-start
  22. // @license GPL-3.0-or-later; http://www.gnu.org/licenses/gpl-3.0.txt
  23. // @noframes
  24. // ==/UserScript==
  25.  
  26. (function() {
  27. 'use strict';
  28.  
  29. function injected() {
  30. const OPTIONS = {
  31. colorR: 0.5,
  32. colorG: 0.5,
  33. colorB: 0.5,
  34. colorRS: 0,
  35. colorGS: 0,
  36. colorBS: 0,
  37. };
  38.  
  39. // If the script breaks, search devtools for "BINTULU" and replace these lines with the new one
  40. const vertexOld = "const float f=3.1415926;varying vec3 a;uniform vec4 b;attribute vec3 c;attribute vec2 d;uniform mat4 e;void main(){vec4 g=vec4(c,1);gl_Position=e*g;a=vec3(d.xy*b.xy+b.zw,1);a*=length(c);}";
  41. const fragOld = "precision highp float;const float h=3.1415926;varying vec3 a;uniform vec4 b;uniform float f;uniform sampler2D g;void main(){vec4 i=vec4(texture2DProj(g,a).rgb,f);gl_FragColor=i;}";
  42.  
  43. const vertexNew = `
  44. const float f=3.1415926;
  45. varying vec3 a;
  46. varying vec3 potato;
  47. uniform vec4 b;
  48. attribute vec3 c;
  49. attribute vec2 d;
  50. uniform mat4 e;
  51. void main(){
  52. vec4 g=vec4(c,1);
  53. gl_Position=e*g;
  54. a = vec3(d.xy * b.xy + b.zw,1);
  55. a *= length(c);
  56.  
  57. potato = vec3(d.xy, 1.0) * length(c);
  58. }`;
  59. const fragNewBaidu = `precision highp float;
  60. const float h=3.1415926;
  61. varying vec3 a;
  62. varying vec3 potato;
  63. uniform vec4 b;
  64. uniform float f;
  65. uniform sampler2D g;
  66. void main(){
  67.  
  68. vec2 aD = potato.xy / a.z;
  69. float thetaD = aD.y;
  70.  
  71. float thresholdD1 = 0.61;
  72. float thresholdD2 = 0.61;
  73.  
  74. float x = aD.x;
  75. float y = abs(4.0*x - 2.0);
  76. float phiD = smoothstep(0.0, 1.0, y > 1.0 ? 2.0 - y : y);
  77.  
  78. vec4 i = vec4(
  79. thetaD > mix(thresholdD1, thresholdD2, phiD)
  80. ? vec3(float(${OPTIONS.colorR}), float(${OPTIONS.colorG}), float(${OPTIONS.colorB})) // texture2DProj(g,a).rgb * 0.25
  81. : texture2DProj(g,a).rgb
  82. ,f);
  83. gl_FragColor=i;
  84. }`;
  85.  
  86. const fragNew = `precision highp float;
  87. const float h=3.1415926;
  88. varying vec3 a;
  89. varying vec3 potato;
  90. uniform vec4 b;
  91. uniform float f;
  92. uniform sampler2D g;
  93. void main(){
  94.  
  95. vec2 aD = potato.xy / a.z;
  96. float thetaD = aD.y;
  97.  
  98. float thresholdD1 = 0.6;
  99. float thresholdD2 = 0.7;
  100.  
  101. float x = aD.x;
  102. float y = abs(4.0*x - 2.0);
  103. float phiD = smoothstep(0.0, 1.0, y > 1.0 ? 2.0 - y : y);
  104.  
  105. vec4 i = vec4(
  106. thetaD > mix(thresholdD1, thresholdD2, phiD)
  107. ? vec3(float(${OPTIONS.colorR}), float(${OPTIONS.colorG}), float(${OPTIONS.colorB})) // texture2DProj(g,a).rgb * 0.25
  108. : texture2DProj(g,a).rgb
  109. ,f);
  110. gl_FragColor=i;
  111. }`;
  112.  
  113. const fragNewBaiduNew = `precision highp float;
  114. const float h=3.1415926;
  115. varying vec3 a;
  116. varying vec3 potato;
  117. uniform vec4 b;
  118. uniform float f;
  119. uniform sampler2D g;
  120. void main(){
  121.  
  122. vec2 aD = potato.xy / a.z;
  123. float thetaD = aD.y;
  124.  
  125. float thresholdD1 = 0.6;
  126. float thresholdD2 = 0.7;
  127.  
  128. float thresholdD1S = 0.8;
  129. float thresholdD2S = 0.9;
  130.  
  131. float x = aD.x;
  132. float y = abs(4.0*x - 2.0);
  133. float phiD = smoothstep(1.0, 0.0, y > 1.0 ? 2.0 - y : y);
  134.  
  135. vec4 i = vec4(
  136. thetaD > mix(thresholdD1, thresholdD2, phiD)
  137. ? (thetaD > mix(thresholdD1S, thresholdD2S, phiD) ? vec3(float(${OPTIONS.colorRS}), float(${OPTIONS.colorGS}), float(${OPTIONS.colorBS})) : vec3(float(${OPTIONS.colorR}), float(${OPTIONS.colorG}), float(${OPTIONS.colorB})))
  138. : texture2DProj(g,a).rgb
  139. ,f);
  140. gl_FragColor=i;
  141. }`;
  142. let streetViewPanorama, isBaiduP = false;
  143. //let tryInit = setInterval(function(){
  144. // const streetViewContainer = document.getElementById('viewer');
  145. // if (streetViewContainer){
  146. // const keys = Object.keys(streetViewContainer);
  147. // const key = keys.find(key => key.startsWith("__reactFiber"));
  148. // const props = streetViewContainer[key];
  149. // streetViewPanorama = props.return.child.memoizedProps.children[1].props.googleMapInstance;
  150. // if (streetViewPanorama) {
  151. // streetViewPanorama.addListener('position_changed', () => {
  152. // // console.log(streetViewPanorama.getPano());
  153. // // console.log(/^[A-Z0-9]{27}$/.test(streetViewPanorama.getPano()));
  154. // if (/^[A-Z0-9]{27}$/.test(streetViewPanorama.getPano())) {
  155. // isBaiduP = true;
  156. // }
  157. // });
  158. // clearInterval(tryInit);
  159. // }
  160. // }
  161. //}, 100);
  162.  
  163. var _send = XMLHttpRequest.prototype.send;
  164. XMLHttpRequest.prototype.send = function(value) {
  165. this.addEventListener('load', function() {
  166. if (this.responseURL && this.responseURL.includes('https://tuxun.fun/api/v0/tuxun/mapProxy/getPanoInfo?pano=') && this.responseURL.length == 84) {
  167. isBaiduP = true;
  168. }
  169. }, false);
  170. _send.call(this, value);
  171. };
  172.  
  173.  
  174. function installShaderSource(ctx) {
  175. const g = ctx.shaderSource;
  176. function shaderSource() {
  177. if (typeof arguments[1] === 'string') {
  178. let glsl = arguments[1];
  179. //console.log('BINTULU shader', glsl);
  180.  
  181. if (glsl === vertexOld) glsl = vertexNew;
  182. else if (glsl === fragOld){
  183. if (isBaiduP) glsl = fragNewBaiduNew;
  184. else glsl = fragNew;
  185. }
  186. return g.call(this, arguments[0], glsl);
  187. }
  188. return g.apply(this, arguments);
  189. }
  190. shaderSource.bestcity = 'bintulu';
  191. ctx.shaderSource = shaderSource;
  192. }
  193. function installGetContext(el) {
  194. const g = el.getContext;
  195. el.getContext = function() {
  196. if (arguments[0] === 'webgl' || arguments[0] === 'webgl2') {
  197. const ctx = g.apply(this, arguments);
  198. if (ctx && ctx.shaderSource && ctx.shaderSource.bestcity !== 'bintulu') {
  199. installShaderSource(ctx);
  200. }
  201. return ctx;
  202. }
  203. return g.apply(this, arguments);
  204. };
  205. }
  206. const f = document.createElement;
  207. document.createElement = function() {
  208. if (arguments[0] === 'canvas' || arguments[0] === 'CANVAS') {
  209. const el = f.apply(this, arguments);
  210. installGetContext(el);
  211. return el;
  212. }
  213. return f.apply(this, arguments);
  214. };
  215. function addCompassStyle() {
  216. let style = document.createElement('style');
  217. style.id = 'bintulu_nocompass';
  218. style.innerHTML = '.gmnoprint.gm-bundled-control.gm-bundled-control-on-bottom { display: none }';
  219. document.head.appendChild(style);
  220. }
  221. addCompassStyle();
  222. document.addEventListener('keydown', (evt) => {
  223. if (!evt.repeat && evt.code === 'KeyK' && evt.shiftKey && !evt.altKey && !evt.ctrlKey && !evt.metaKey) {
  224. let style = document.getElementById('bintulu_nocompass');
  225. if (!style) {
  226. addCompassStyle();
  227. } else {
  228. style.remove();
  229. }
  230. }
  231. });
  232. }
  233.  
  234. unsafeWindow.eval(`(${injected.toString()})()`);
  235.  
  236. })();