Skip to content

Instantly share code, notes, and snippets.

@Risyandi
Created June 29, 2024 15:28
Show Gist options
  • Save Risyandi/1542ff1e3c96fc2b5b0ed8d70463fe3e to your computer and use it in GitHub Desktop.
Save Risyandi/1542ff1e3c96fc2b5b0ed8d70463fe3e to your computer and use it in GitHub Desktop.
get url in element and saved to text file
// class you can modify based on the target
// count length of element base on the target
let arrayValue = [];
let element = document.querySelectorAll('.project-cell.gl-w-11 a');
let length = document.querySelectorAll('.project-cell.gl-w-11 a').length;
for (let index = 0; index < length; index++) {
// get value of href in the element
// push value to array
let result = element[index].href;
arrayValue.push(result);
}
// create a element anchor, adding href in element and download, and then action to click
let link = document.createElement("a");
let filename = "gitlabUrl.txt";
let file = new Blob([arrayValue], {
type: "text/plain;charset=utf-8"
});
link.href = URL.createObjectURL(file);
link.download = filename;
link.click();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment