GeoNoCar lite

Hides part of the panorama to redact non-trekker gen 3 car meta

当前为 2023-02-11 提交的版本,查看 最新版本

// ==UserScript==
// @name         GeoNoCar lite
// @description  Hides part of the panorama to redact non-trekker gen 3 car meta
// @version      0.2.1
// @author       victheturtle#5159
// @match        https://www.geoguessr.com/*
// @namespace    https://gf.qytechs.cn/users/967692-victheturtle
// @icon         https://www.svgrepo.com/show/180174/pickup-truck-transport.svg
// @grant        unsafeWindow
// @run-at       document-start
// @license GPL-3.0-or-later; http://www.gnu.org/licenses/gpl-3.0.txt
// @noframes
// ==/UserScript==

// credits to drparse for the original GeoNoCar script

function injected() {
    const OPTIONS = {
        colorR: 0.3,
        colorG: 0.3,
        colorB: 0.3,
    };

    // If the script breaks, search devtools for "BINTULU" and replace these lines with the new one
    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);}";
    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;}";

    const vertexNew = `
varying vec3 a;
varying vec3 potato;
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);

    potato = vec3(d.xy, 1.0) * length(c);
}`;
    const fragNew = `
precision highp float;
varying vec3 a;
varying vec3 potato;
uniform vec4 b;
uniform float f;
uniform sampler2D g;

bool show(float alpha1, float alpha2) {
    float alpha3 = abs(alpha1 - 0.5);
    float alpha4 = (alpha3 > 0.25) ? 0.5 - alpha3 : alpha3;

    if (alpha4 < 0.0062) {
        return alpha2 > 0.63;
    } else if (alpha4 < 0.0066) {
        return alpha2 > mix(0.63, 0.67, (alpha4-0.0062) / (0.0066-0.0062));
    } else if (alpha4 < 0.065) {
        return alpha2 > 0.67;
    } else if (alpha4 < 0.10) {
        return alpha2 > mix(0.67, 0.715, (alpha4-0.065) / (0.10-0.065));
    } else if (alpha4 < 0.16) {
        return alpha2 > mix(0.715, 0.73, (alpha4-0.10) / (0.16-0.10));
    } else if (alpha4 < 0.175) {
        return alpha2 > mix(0.73, 0.79, (alpha4-0.16) / (0.175-0.16));
    } else if (alpha4 < 0.25) {
        return alpha2 > 0.81 - 3.5 * (alpha4 - 0.25) * (alpha4 - 0.25);
    } else {
        float thresholdD1 = 0.66;
        float thresholdD2 = 0.76;
        float y = abs(4.0*alpha1 - 2.0);
        float phiD = smoothstep(0.0, 1.0, y > 1.0 ? 2.0 - y : y);
        return alpha2 > mix(thresholdD1, thresholdD2, phiD);
    }
}

void main(){
    vec2 aD = potato.xy / a.z;
    vec4 i = vec4(
        show(aD.x, aD.y)
        ? vec3(float(${OPTIONS.colorR}), float(${OPTIONS.colorG}), float(${OPTIONS.colorB}))
        //? texture2DProj(g,a).rgb * 0.5
        : texture2DProj(g,a).rgb
        , f);
    gl_FragColor=i;
}`;

    function installShaderSource(ctx) {
        const oldShaderSource = ctx.shaderSource;
        function shaderSource() {
            if (typeof arguments[1] === 'string') {
                let glsl = arguments[1];
                if (glsl === vertexOld) glsl = vertexNew;
                else if (glsl === fragOld) glsl = fragNew;
                return oldShaderSource.call(this, arguments[0], glsl);
            }
            return oldShaderSource.apply(this, arguments);
        }
        shaderSource.bestcity = 'bintulu';
        ctx.shaderSource = shaderSource;
    }
    function installGetContext(el) {
        const oldGetContext = el.getContext;
        el.getContext = function() {
            if (arguments[0] === 'webgl' || arguments[0] === 'webgl2') {
                const ctx = oldGetContext.apply(this, arguments);
                if (ctx && ctx.shaderSource && ctx.shaderSource.bestcity !== 'bintulu') {
                    installShaderSource(ctx);
                }
                return ctx;
            }
            return oldGetContext.apply(this, arguments);
        };
    }
    const oldCreateElement = document.createElement;
    document.createElement = function() {
        if (arguments[0] === 'canvas' || arguments[0] === 'CANVAS') {
            const el = oldCreateElement.apply(this, arguments);
            installGetContext(el);
            return el;
        }
        return oldCreateElement.apply(this, arguments);
    };
}

unsafeWindow.eval(`(${injected.toString()})()`);

QingJ © 2025

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