Discussions » Development

Trying to figure out what isn't working with my script I've recently ( TRIED ) creating.

§
Posted: 2019-12-31
Edited: 2020-01-02

Trying to figure out what isn't working with my script I've recently ( TRIED ) creating.

( Im making a script for a game called diep.io ) So I've tried loading Jquery and then, under it making the actual script itself. Apparently there is something that tampermonkey does not like about this, what am I doing wrong? :

// ==UserScript==
// @name         Machine Gun --> Destroyer
// @version      1.0
// @description  This will make you automatically switch to destroyer when pressing "R" ( Useful for sandbox or betraying teamers )
// @author       S O-P
// @match        https://www.reddit.com/r/diepio_scripts/
// @include  http://diep.io/*
// @connect  diep.io
// @namespace  N/A
// @require http://code.jquery.com/jquery-latest.js
// ==/UserScript==
function addJQuery(callback) {
    var script = document.createElement("script");
    script.setAttribute("src", "//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js");
    script.addEventListener('load', function() {
        var script = document.createElement("script");
        script.textContent = "window.jQ=jQuery.noConflict(true);(" + callback.toString() + ")();";
        document.body.appendChild(script);
    }, false);
    document.body.appendChild(script);
}
function main(){
    $(document).ready(function()
                      {
                          setTimeout(function(){
                              /*$('.fluid_types').val('Liquid');
                              $('.fluid_types').triggerHandler('change');
                              setTimeout(function(){
                                  $('.fluids').val('Ammonia');
                              },500);*/
                              $('.fluid_types').triggerHandler('change');
                              $('.flow_unit_1').val('lb');
                              $('.flow_unit_2').val('sec');
                              $('.min_flow').val(1);
                              $('.nom_flow').val(2);
                              $('.max_flow').val(8);
                              $('.min_temp').val(280);
                              $('.nom_temp').val(280);
                              $('.max_temp').val(280);
                              //$('.min_press').val(10);
                              //$('.nom_press').val(10);
                              //$('.max_press').val(20);
                              setTimeout(function(){
                                  $('#button_calc').triggerHandler('click');
                                  setTimeout(function(){
                                      $('.icon_size').triggerHandler('click');
                                  },500);
                              },500);
                          },2000);
                      });
}
// load jQuery and execute the main function
addJQuery(main);

window.addEventListener("keydown", checkKeyPressed, false);

function checkKeyPressed(evt) {
    if (evt.keyCode == "114") {
function click(x,y){
    var ev = document.createEvent("MouseEvent");
    var el = document.elementFromPoint(x,y);
    ev.initMouseEvent(
        "click",
        true /* bubble */, true /* cancelable */,
        window, null,
        x, y, 94, 109, /* coordinates */
        false, false, false, false, /* modifier keys */
        0 /*left*/, null
    );
    el.dispatchEvent(ev);
}
   }
  }

Post reply

Sign in to post a reply.