diff options
author | Elias Fleckenstein <eliasfleckenstein@web.de> | 2022-03-04 22:12:01 +0100 |
---|---|---|
committer | Elias Fleckenstein <eliasfleckenstein@web.de> | 2022-03-04 22:12:01 +0100 |
commit | f0cb1873fa077cb82c8d3416a4c74386865c8e7d (patch) | |
tree | 512af92ef9fb64d1f6ab1369efbae6422ffdddfb | |
parent | 9ce3e65de157c71a1bfd9a5e6e1242ffd55f6a79 (diff) | |
download | google_images-f0cb1873fa077cb82c8d3416a4c74386865c8e7d.tar.xz |
Fix width/height being swapped
-rw-r--r-- | README.md | 4 | ||||
-rw-r--r-- | init.js | 9 |
2 files changed, 6 insertions, 7 deletions
@@ -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', @@ -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])) |