BiCH0 / Owasp top 10 fetcher

// ==UserScript==
// @name        Owasp top 10 fetcher
// @namespace   Violentmonkey Scripts
// @match       https://owasp.org/Top10/*
// @grant       none
// @version     1.0
// @author      BiCH0
// @description 4/9/2024, 5:58:03 PM
// @license MIT
// @copyright 2024, BiCH0 (https://openuserjs.org/users/BiCH0)
// ==/UserScript==
/*jshint esversion: 8 */
var sleep = function(ms){
    return new Promise(resolve => setTimeout(resolve, ms));
};

const functions = ["fetchCWEs"]
window.fetchCWEs = async function (btn){
  console.log("Fetching CWEs...");
  let list = document.getElementById("list-of-mapped-cwes");
  let codes = "";
  list = list.parentNode.getElementsByTagName("a");
  for (let i=0; i < list.length; i++){
    let split = list[i].href.split("/");
    if (split[2] == "cwe.mitre.org"){
        codes+=split[split.length-1].split(".")[0]+", ";
    }
  }
  codes=codes.slice(0,-2);
  navigator.clipboard.writeText(codes);
  if (codes != ""){
     btn.value = "Values copied to clipboard";
  }else{
    btn.value = "Try again";
  }
  await sleep(2000);
  btn.value = "fetchCWEs";
}

function drawOverlay (){
  let buttons = "";
  functions.forEach(fn => {
    buttons+=`<input type='button' onclick='${fn}(this)' value='${fn}' style='background: red; color: white; border-radius: 5px'>`;
  });
  document.body.innerHTML+=`<div id='violent-buttons' style='position: fixed;left: 35%;top: 15px;z-index: 2000;'>${buttons}</div>`;
}
drawOverlay()