bradley6597 commited on
Commit
fe4717f
1 Parent(s): 7c77316

Created a separate file for javascript functions

Browse files
Files changed (1) hide show
  1. js_functions.js +29 -0
js_functions.js ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ async function magicFunc(x){
2
+ let z = document.getElementById('search_term').getElementsByTagName('textarea')[0].value;
3
+ await fetch('/track?url=' + x + '&q=' + z)
4
+ }
5
+
6
+ function delay(x) {
7
+ setTimeout(() => {
8
+ var isLoaded = x.getElementsByTagName('img')[0].complete
9
+ console.log('is Loaded: ', isLoaded)
10
+ if(!isLoaded){
11
+ delay(x)
12
+ }else{
13
+ x.getElementsByClassName('submit-btn')[0].innerText = 'Drag It!'
14
+ }
15
+ // Set the flag to true to indicate to break the loop
16
+ }, 2000);
17
+ }
18
+
19
+ function mdFunc(x) {
20
+ let counter = 0;
21
+ var imgUrl = x.getElementsByTagName('img')[0].src;
22
+ var rx = RegExp('(.*)\\=w320.*');
23
+ var imgUrl = imgUrl.replace(rx, "$1");
24
+ x.getElementsByTagName('img')[0].src = imgUrl;
25
+ x.getElementsByClassName('submit-btn')[0].innerText = 'Loading...'
26
+ delay(x)
27
+ var imgID = imgUrl.replace('https://lh3.google.com/u/0/d/', '');
28
+ magicFunc(imgID)
29
+ }