]> git.lizzy.rs Git - google_images.git/commitdiff
Fix width/height being swapped
authorElias Fleckenstein <eliasfleckenstein@web.de>
Fri, 4 Mar 2022 21:12:01 +0000 (22:12 +0100)
committerElias Fleckenstein <eliasfleckenstein@web.de>
Fri, 4 Mar 2022 21:12:01 +0000 (22:12 +0100)
README.md
init.js

index ac1c7c3983114d3e1431070da4d39c004f91c519..d2efdf13bc8f4ed40e7ea3206fb3eb3edadb0f41 100644 (file)
--- a/README.md
+++ b/README.md
@@ -10,11 +10,11 @@ Exports `search` function that takes query string as first argument and optional
 {
        preview: {
                url: 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQpttHz6N94mnwy5NbULk733B3srNYPMsmaYQ&usqp=CAU',
-               size: { width: 168, height: 300 }
+               size: { width: 300, height: 168 }
        },
        image: {
                url: 'https://en.free-wallpapers.su/data/media/3/big/anm5679.jpg',
-               size: { width: 1080, height: 1920 }
+               size: { width: 1920, height: 1080 }
        },
        color: 'rgb(232,190,194)',
        link: 'https://en.free-wallpapers.su/img116919.htm',
diff --git a/init.js b/init.js
index 48488910793c60de86d6875f45ec9cb108f72cb8..d5f3e5236f43a56d0877285d17941a53df49e4dd 100644 (file)
--- a/init.js
+++ b/init.js
@@ -23,11 +23,10 @@ const findStrings = (obj, path = "") => {
                let t = typeof v;
                let p = path + "." + k
 
-               
                if (t == "object")
                        found = found.concat(findStrings(v, p));
                else if (t == "string")
-                       found.push([v, p]);             
+                       found.push([v, p]);
        }
 
        return found;
@@ -47,8 +46,8 @@ const makeImage = elem => {
        return {
                url: elem[0],
                size: {
-                       width: elem[1],
-                       height: elem[2],
+                       width: elem[2],
+                       height: elem[1],
                }
        }
 };
@@ -62,7 +61,7 @@ module.exports.search = (query, userAgent = "Mozilla/5.0 (X11; Ubuntu; Linux x86
                .then(scripts => scripts.map(script => script.children[0]?.data))
                .then(scripts => scripts.filter(script => script?.search("http") >= 0))
                .then(scripts => scripts[4])
-               .then(script => script.slice("AF_initDataCallback(".length, script.length - ");".length))
+               .then(script => script.slice("AF_ini2tDataCallback(".length, script.length - ");".length))
                .then(jsonic)
                .then(data => data.data[31][0][12][2])
                .then(data => data.map(elem => elem[1]))