gdrive-illustration-search / js_functions.js
bradley6597's picture
Created a separate file for javascript functions
fe4717f
raw
history blame
939 Bytes
async function magicFunc(x){
let z = document.getElementById('search_term').getElementsByTagName('textarea')[0].value;
await fetch('/track?url=' + x + '&q=' + z)
}
function delay(x) {
setTimeout(() => {
var isLoaded = x.getElementsByTagName('img')[0].complete
console.log('is Loaded: ', isLoaded)
if(!isLoaded){
delay(x)
}else{
x.getElementsByClassName('submit-btn')[0].innerText = 'Drag It!'
}
// Set the flag to true to indicate to break the loop
}, 2000);
}
function mdFunc(x) {
let counter = 0;
var imgUrl = x.getElementsByTagName('img')[0].src;
var rx = RegExp('(.*)\\=w320.*');
var imgUrl = imgUrl.replace(rx, "$1");
x.getElementsByTagName('img')[0].src = imgUrl;
x.getElementsByClassName('submit-btn')[0].innerText = 'Loading...'
delay(x)
var imgID = imgUrl.replace('https://lh3.google.com/u/0/d/', '');
magicFunc(imgID)
}