Skip to content

Instantly share code, notes, and snippets.

@sergiosusa
Last active May 9, 2022 10:44
Show Gist options
  • Save sergiosusa/81e5ec030739be6d86bf9667ffc9da26 to your computer and use it in GitHub Desktop.
Save sergiosusa/81e5ec030739be6d86bf9667ffc9da26 to your computer and use it in GitHub Desktop.
Accident Creation Tool
// ==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