From: Elias Fleckenstein Date: Fri, 4 Mar 2022 21:12:01 +0000 (+0100) Subject: Fix width/height being swapped X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=f0cb1873fa077cb82c8d3416a4c74386865c8e7d;p=google_images.git Fix width/height being swapped --- diff --git a/README.md b/README.md index ac1c7c3..d2efdf1 100644 --- 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 4848891..d5f3e52 100644 --- 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]))