Greasy Fork

Translator Portal Ease of Use

Adds a Skip button for invalid translations.

当前为 2021-06-29 提交的版本,查看 最新版本

// ==UserScript==
// @name         Translator Portal Ease of Use
// @namespace    https://www.roblox.com/games/263761432/Horrific-Housing
// @version      1.2.3
// @description  Adds a Skip button for invalid translations.
// @author       wut
// @match        https://www.roblox.com/localization/games/*/translations?languageCode=*
// @icon         https://cdn.discordapp.com/attachments/685584087376986124/859100206297120778/unknown.png
// @grant        none
// ==/UserScript==

// IS THE SITE LOADED?
window.addEventListener("load", function(){

    // CREATING THE BUTTON
	var clone = document.querySelector('#selenium-save-entry-button').cloneNode( true );
	clone.setAttribute('id', 'selenium-skip-button');
	document.querySelectorAll('.col-sm-6')[2].appendChild( clone );
	clone.innerHTML = "Skip";
	document.getElementById("selenium-skip-button").style.marginRight = "10px";
	clone.removeAttribute("disabled")

	// DEFINING THE INPUT TEXTBOX
	var inputbox = document.getElementById("selenium-translation-text");

	// INVALID BUTTON LISTENER FUNCTION
	document.getElementById("selenium-skip-button").addEventListener("click", function() {

		// COPYING AND PASTING THE TEXT
		inputbox.value = document.getElementById("selenium-entry-source-text").innerHTML;
		inputbox.innerHTML = document.getElementById("selenium-entry-source-text").innerHTML;
		inputbox.classList.remove("ng-pristine");
		inputbox.classList.remove("ng-empty");
		inputbox.classList.add("ng-valid");
		inputbox.classList.add("ng-not-empty");
		inputbox.classList.add("ng-dirty");
		inputbox.classList.add("ng-valid-parse");

		// MANUAL TEXTBOX UPDATE (IMPORTANT)
		if ("createEvent" in document) {
			var evt = document.createEvent("HTMLEvents");
			evt.initEvent("change", false, true);
			inputbox.dispatchEvent(evt);
		}
		else {
			inputbox.fireEvent("onchange");
		}

		// AUTOMATICALLY CLICK SAVE
		var save = document.querySelector('#selenium-save-entry-button');
		save.click();

	});
});