I have very little coding experience and just learn from looking things up and trying it. I've never dealt with javascript before so please try to be specific.
I'm looking to create a bookmarklet to automate video downloads. This is what I've found so far through searching:
document.getElementsByClassName('class_name')[0].innerHTML
// used to output to console the value of the class
document.getElementsByClassName('class_name')[0].click()
// used to click on a specific class
function copyToClipboard(text) {
var dummy = document.createElement("textarea");
// to avoid breaking orgain page when copying more words
// cant copy when adding below this code
// dummy.style.display = 'none'
document.body.appendChild(dummy);
//Be careful if you use texarea. setAttribute('value', value), which works with "input" does not work with "textarea". – Eduard
dummy.value = text;
dummy.select();
document.execCommand("copy");
document.body.removeChild(dummy);
}
//The above is a function used to copy data to the clipboard.
This is how I'm imagining it to work after clicking the bookmarklet:
copyToClipboard(document.getElementsByClassName('video_name')[0].innerHTML)
// this will copy the video name to the clipboard
document.getElementsByClassName('download_button')[0].click()
// this will click the download button which opens the resolutions list
document.getElementsByClassName('resolution')[0].click()
// this will click the top most resolution in the downloads list
This is the part where I'm stuck. The file explorer now opens up to set the location and the name to save as. How do I implement the bookmarklet such that it will paste the clipboard contents into the "File name" field in file explorer (it is already automatically selected on that field) and then how do I get it to click the "Save" button.
Thanks for the help!