Log in

View Full Version : Automatically insert your coordinates into the Vahaduo "Target" tab



sacha
08-31-2024, 08:03 PM
I am lazy and want to enable myself to be lazier, so I have made a script (well technically two I guess) that lets me automatically have my coordinates in the Vahaduo "Target" tab. You can use this too.

For both of the options I specified below, follow the mini guide (it is braindead levels of easy don't worry) I put at the top of my TA scripts thread (https://www.theapricity.com/forum/showthread.php?387305-TA-Utility-Scripts). Option 1 requires less setup but is slightly more annoying to modify later, so I recommend Option 2.

Option 1

This method means you are just specifying what you want inserted in a *string* at the top of the code. If you have any newlines, you have to remove them and replace them with "\n". For example if I wanted to add:


EPIC_COOL_VIKING,1,2,3,4,5
UNCOOL_WEIRD_VIKING,2,3,4,5,6

You need to replace
var textToInsert = "Texttttt";
with
var textToInsert = "EPIC_COOL_VIKING,1,2,3,4,5\nUNCOOL_WEIRD_VIKING,2, 3,4,5,6";
Other than that, it should work automatically. If your internet is really slow, you might have to increase the number at the bottom to like 1000 or 2000, but I doubt you will need to.



// ==UserScript==
// @name Vahaduo Target Insert (Manual String)
// @namespace http://tampermonkey.net/
// @version 1.0
// @description i am lazy :p
// @author sacha
// @match https://vahaduo.github.io/vahaduo/
// @grant none
// ==/UserScript==

(function() {
'use strict';

// Text here
var textToInsert = "Texttttt";

function insertTextIfEmpty(text) {
const textarea = document.getElementById("target");
if (textarea) {
if (textarea.value.trim() === "") {
textarea.value = text;
textarea.dispatchEvent(new Event('input'));
textarea.dispatchEvent(new Event('change'));
} else {
console.log("Textarea is not empty. Skipping text insertion.");
}
} else {
console.log("Textarea not found.");
}
}

setTimeout(() => {
insertTextIfEmpty(textToInsert);
}, 500); // If it isn't working try making this higher
})();



Option 2

For this option you will need to specify your content in an external text file. Unfortunately, sites like Pastebin don't allow you to automatically fetch the text using Tampermonkey because of their CORS specifications (don't worry about it, it's actually quite easy to get around with a proxy tbh but I didn't want to use that in a script like this). I host my own websites so I was able to get around this, but if you do not do that I think the easiest option is to make a free site on neocities.org, then upload a .txt file with your desired input there and insert the link of that. It's easy to edit in browser later too.


// ==UserScript==
// @name Vahaduo Target Insert
// @namespace http://tampermonkey.net/
// @version 1.0
// @description i am lazy :p
// @author sacha
// @match https://vahaduo.github.io/vahaduo/
// @grant none
// ==/UserScript==

(function() {
'use strict';

var txtFileUrl = "https://yourlinkgoeshere/abc.txt";

function fetchAndInsertTextIfEmpty(url) {
const textarea = document.getElementById("target");
if (textarea) {
if (textarea.value.trim() === "") {
fetch(url)
.then(response => response.text())
.then(text => {
textarea.value = text;
textarea.dispatchEvent(new Event('input'));
textarea.dispatchEvent(new Event('change'));
})
.catch(error => console.error("Error fetching the file:", error));
} else {
console.log("Textarea is not empty. Skipping fetch.");
}
} else {
console.log("Textarea not found.");
}
}

setTimeout(() => {
fetchAndInsertTextIfEmpty(txtFileUrl);
}, 500); // If it isn't working try making this higher
})();



Pls note they only work if the target is empty-- Vahaduo saves your input for a little bit even if you reload, so remove then reload if you want them immediately

sacha
08-31-2024, 08:03 PM
Oh I posted this too early one second haha

Edit: Okay it is fixed. I am thinking of also making a script that automatically loads the default G25 files in the "Data" section as well, if I do that I will update it here in this thread.