Last active
May 9, 2022 10:44
-
-
Save sergiosusa/81e5ec030739be6d86bf9667ffc9da26 to your computer and use it in GitHub Desktop.
Accident Creation Tool
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Accident Creation Tool | |
// @namespace ADM Team | |
// @version 0.2 | |
// @description Accident Creation Tool | |
// @author You | |
// @match https://*.retailservices.audi.de/*/*/accidents/create-form | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=audi.de | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
setTimeout(function(){ | |
let titleNode = document.querySelector("#awsiadm_createAccident_damageHeadline"); | |
let extraButtons = '<a id="mark-all" href="javascript:void(0)">( Mark all damages )</a>'+ | |
'<a id="mark-severity" href="javascript:void(0)">( Mark random severity )</a>'; | |
titleNode.innerHTML = titleNode.innerHTML + extraButtons; | |
document.querySelector("#mark-all").onclick = markDamages; | |
document.querySelector("#mark-severity").onclick = markRandomSeverity; | |
}, 2000); | |
})(); | |
function getRandomInt(min, max) { | |
return parseInt((Math.random() * (max - min) + min)); | |
} | |
function markDamages(){ | |
document.querySelectorAll("#awsiadm_createAccident_damage .aui-checkbox__input").forEach(function(element){element.click();}); | |
} | |
function markRandomSeverity(){ | |
document.querySelectorAll(".radioBoxWrapper").forEach(function(element){ | |
let damageType = element.querySelectorAll("input"); | |
damageType[getRandomInt(0, damageType.length)].click(); | |
}); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment