r!PsAw small mod

autorespawn, redrawing player, copy party link, leave game, no privacy settings button, no apes.io advertisment

当前为 2024-08-09 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         r!PsAw small mod
// @namespace    http://tampermonkey.net/
// @version      0.0.2
// @description  autorespawn, redrawing player, copy party link, leave game, no privacy settings button, no apes.io advertisment
// @author       You
// @match        https://diep.io/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=diep.io
// @grant        none
// @license      MIT
// ==/UserScript==

// Mouse coordinates
var uwuX = '0'; var uwuY = '0';
document.addEventListener('mousemove', function(e) {
   uwuX = e.clientX;
   uwuY = e.clientY;
});

//remove privacy settings button and apes.io promo
setTimeout(() => {
document.getElementById("cmpPersistentLink").remove();
document.getElementById("apes-io-promo").remove();
}, 2500);

//toggle leave game
let active = false;
let s = false;
let ingame_quit_btn = document.getElementById("quick-exit-game");
let app = document.getElementById("app");

function check_class(){
  if(ingame_quit_btn.classList.contains("shown")){
      active = false;
  }else if(ingame_quit_btn.classList.contains("hidden")){
      active = true;
  }
}

setInterval(check_class, 300);

var toggle_quit_btn = document.createElement('button');
toggle_quit_btn.innerHTML = `leave button active? ${active}`;
toggle_quit_btn.style.color = "white";
toggle_quit_btn.style.position = "fixed";
toggle_quit_btn.style.width = "100px";
toggle_quit_btn.style.height = "50px";
toggle_quit_btn.style.bottom = "20%";
toggle_quit_btn.style.left = "20%";
toggle_quit_btn.style.transform = "translate(-50%, 50%)";
toggle_quit_btn.style.cursor = "pointer";
toggle_quit_btn.style.zIndex = '9999';
toggle_quit_btn.onclick = function() {
   s = !s;
  toggle_quit_btn.innerHTML = `leave button active? ${active}`;
  if(s){
   ingame_quit_btn.classList.remove("hidden");
   ingame_quit_btn.classList.add("shown");
  }else{
   ingame_quit_btn.classList.remove("shown");
   ingame_quit_btn.classList.add("hidden");
  }
}

app.appendChild(toggle_quit_btn);

//autorespawn (easy way)
let ingamescreen = document.getElementById("in-game-screen");
let autorespawn = false;
function respawn(){
 if(autorespawn){
  if(ingamescreen.classList.contains("screen") && ingamescreen.classList.contains("active")){
   return;
  }else{
    let spawnbtn = document.getElementById("spawn-button");
    spawnbtn.click();
  }
 }
}

setInterval(respawn, 1000);

var toggle_auto_r_btn = document.createElement('button');
toggle_auto_r_btn.innerHTML = `auto respawn active? ${autorespawn}`;
toggle_auto_r_btn.style.color = "white";
toggle_auto_r_btn.style.position = "fixed";
toggle_auto_r_btn.style.width = "100px";
toggle_auto_r_btn.style.height = "50px";
toggle_auto_r_btn.style.bottom = "20%";
toggle_auto_r_btn.style.left = "25%";
toggle_auto_r_btn.style.transform = "translate(-50%, 50%)";
toggle_auto_r_btn.style.cursor = "pointer";
toggle_auto_r_btn.style.zIndex = '9999';
toggle_auto_r_btn.onclick = function() {
   autorespawn = !autorespawn;
   toggle_auto_r_btn.innerHTML = `auto respawn active? ${autorespawn}`;
}

app.appendChild(toggle_auto_r_btn);

//copy party link
var copy_p_link_btn = document.createElement('button');
copy_p_link_btn.innerHTML = `copy party link`;
copy_p_link_btn.style.color = "white";
copy_p_link_btn.style.position = "fixed";
copy_p_link_btn.style.width = "100px";
copy_p_link_btn.style.height = "50px";
copy_p_link_btn.style.bottom = "20%";
copy_p_link_btn.style.left = "30%";
copy_p_link_btn.style.transform = "translate(-50%, 50%)";
copy_p_link_btn.style.cursor = "pointer";
copy_p_link_btn.style.zIndex = '9999';
copy_p_link_btn.onclick = function() {
  document.getElementById("copy-party-link").click();
}

app.appendChild(copy_p_link_btn);

//find the current Level (works only after Level 3 for some reason)
CanvasRenderingContext2D.prototype.fillText = new Proxy(CanvasRenderingContext2D.prototype.fillText, {
    apply(fillRect, ctx, [text, x, y, ...blah]) {
        if (text.startsWith('Lvl ')) {
            currentLevel = text.split(' ')[1];
            tanky = text.split(' ')[2];
        }
        fillRect.call(ctx, text, x, y, ...blah);
    }
});

//Diep Units & fov calculator

/* bugs that I need to fix:

- when increasing level while being Tank, circle radius decreases (to ranger size), but tank body increases

  -> possible solution: (complete tanks table, find the fieldFactors here: https://github.com/ABCxFF/diepindepth/blob/main/extras/tankdefs.json)

- window.resize doesn't check if canvas size changes, but only if the user changes it.

For example opening google console changes canvas size, but user didn't change the window.

-
*/
var currentLevel = 0;
var lastLevel = 0;
var tanky = "";
let ripsaw_radius;
let fieldFactor = 1.0;
let found = false;
let loltank;
const diepUnits = 55;
let FOV = (0.55 * fieldFactor) / Math.pow(1.01, (currentLevel - 1) / 2);
let scalingFactor = FOV * windowScaling();
const fieldFactors = [
    {tank: "Sniper", factor: 0.899},
    {tank: "Overseer", factor: 0.899},
    {tank: "Overlord", factor: 0.899},
    {tank: "Assassin", factor: 0.8},
    {tank: "Necromancer", factor: 0.899},
    {tank: "Hunter", factor: 0.85},
    {tank: "Stalker", factor: 0.8},
    {tank: "Ranger", factor: 0.699},
    {tank: "Manager", factor: 0.899},
    {tank: "Predator", factor: 0.85},
    {tank: "Trapper", factor: 0.899},
    {tank: "Gunner Trapper", factor: 0.899},
    {tank: "Overtrapper", factor: 0.899},
    {tank: "Mega Trapper", factor: 0.899},
    {tank: "Tri-Trapper", factor: 0.899},
    {tank: "Smasher", factor: 0.899},
    {tank: "Landmine", factor: 0.899},
    {tank: "Streamliner", factor: 0.85},
    {tank: "Auto Trapper", factor: 0.899},
    {tank: "Battleship", factor: 0.899},
    {tank: "Auto Smasher", factor: 0.899},
    {tank: "Spike", factor: 0.899},
    {tank: "Factory", factor: 0.899},
    {tank: "Skimmer", factor: 0.899},
    {tank: "Rocketeer", factor: 0.899},
]

function windowScaling() {
  const a = canvas.height / 1080;
  const b = canvas.width / 1920;
  return b < a ? a : b;
}

function calculateFOV(Fv, l) {
    const numerator = 0.55 * Fv;
    console.log("interesting" + l);
    const denominator = Math.pow(1.01, (l - 1) / 2);
    FOV = numerator / denominator;
    return FOV;
}

function apply_values(FF){
        calculateFOV(FF, currentLevel);
        scalingFactor = FOV * windowScaling();
        ripsaw_radius = diepUnits * scalingFactor;
}

function apply_changes(value){
    if(found){
        fieldFactor = fieldFactors[value].factor;
        loltank = tanky;
        lastLevel = currentLevel;
        apply_values(fieldFactor);
    }else{
     if(value === null){
        fieldFactor = 1.0;
        loltank = "default";
        lastLevel = currentLevel;
        apply_values(fieldFactor);
     }
    }
}

function bruteforce_tanks(){
    for (let i = 0; i < fieldFactors.length; i++){
        if(tanky.includes(fieldFactors[i].tank)){
            found = true;
            console.log("FOUND TANK");
            apply_changes(i);
            break;
        }else{
            found = false;
            if(i < fieldFactors.length - 1){
             console.log(`checking tank ${i}`);
            }else{
             console.log("No Tank was found, resetting to default")
             apply_changes(null);
            }
        }
    }
}

window.addEventListener("resize", bruteforce_tanks);

function check_lvl_change() {
    if(lastLevel === currentLevel){
        console.log("level wasn't changed");
    }else{
        console.log("changed level, bruteforcing");
        bruteforce_tanks();
    }
}

function check_change(){
    console.log("lastLevel: " + lastLevel + " currentLevel: " + currentLevel);
    check_lvl_change();
    if(loltank != tanky){
        if(loltank === "default"){
            return;
        }else{
            bruteforce_tanks();
        }
    }
}

setInterval(check_change, 250);

//canvas gui
const ctx = canvas.getContext('2d');
function ctx_text(fcolor, scolor, lineWidth, font, text, textX, textY){
    ctx.fillStyle = fcolor;
    ctx.lineWidth = lineWidth;
    ctx.font = font;
    ctx.strokeStyle = scolor;
    ctx.strokeText(`${text}`, textX, textY)
    ctx.fillText(`${text}`, textX, textY)
}

function ctx_arc(x, y, r, sAngle, eAngle, counterclockwise, c){
    ctx.beginPath();
    ctx.arc(x, y, r, sAngle, eAngle, counterclockwise);
    ctx.fillStyle = c;
ctx.fill();
}

setTimeout(() => {
    let gui = () => {
       if(ingamescreen.classList.contains("screen") && ingamescreen.classList.contains("active")){
        ctx_text("white", "DarkRed", 6, 1.5 + "em Ubuntu", "canvas Lvl:" + currentLevel, canvas.width/20 + 10, 60);
        ctx_text("white", "DarkRed", 6, 1.5 + "em Ubuntu", "canvas tank: " + tanky, canvas.width/20 + 10, 80);
        ctx_text("white", "DarkRed", 6, 1.5 + "em Ubuntu", "radius: " + ripsaw_radius, canvas.width/20 + 10, 100);
        ctx_text("white", "DarkRed", 6, 1.5 + "em Ubuntu", "field Factor: " + fieldFactor, canvas.width/20 + 10, 120);
        if(currentLevel != null && tanky != null){
          ctx.beginPath();
          ctx.moveTo(canvas.width / 2, canvas.height / 2);
          ctx.lineTo(uwuX*2, uwuY*2);
          ctx.stroke();
            ctx_arc(canvas.width / 2, canvas.height / 2, ripsaw_radius, 0, 2 * Math.PI, false, "darkblue");
            ctx_arc(canvas.width / 2, canvas.height / 2, ripsaw_radius*0.9, 0, 2 * Math.PI, false, "lightblue");
        };
       }
        window.requestAnimationFrame(gui);
    }
    gui();
    setTimeout(() => {
        gui();
    },5000);
}, 1000);