Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {"YANDEX_Market-s":{"link":"^market\\.yandex\\.[^/]+/(?:product-|c(?:c|ard)/).*","res":":\nlet newUrl = $._.match(/window\\.location\\.replace\\(\"(.+?)\"\\)/)?.[1] || $[0];\nnewUrl = newUrl.replace(/(\\/reviews)?\\?/, '/reviews?');\n\nlet x = new XMLHttpRequest;\nx.open('GET', newUrl, false);\nx.send();\n$._ = x.responseText + $._;\nconst page = new DOMParser().parseFromString($._, \"text/html\");\n\n// product images\nlet isVideo = (o => o?.video || o?.entity === \"yandex_video\");\nlet hasVideo = false, data = JSON.parse($._.match(/({\"widgets\":{\"@card\\/MediaViewer(?:Gallery|Manager)\":{\"\\/content\\/page\\/fancyPage\\/(?:defaultPage\\/)?mediaViewer.+?})<\\/noframes>/)[1]);\nlet imgs = [];\nObject.values(data.collections.mediaItem).forEach(o => {\n let origImg = isVideo(o) ? ['',`<imagus-extension type=\"videojs\" url=\"${o.streams?.[0]?.url}\"></imagus-extension>${o.title||''}`] : o.origUrl ? [o.origUrl] : '';\n if (isVideo(o)) hasVideo = true;\n // skip duplicates\n if(origImg&&!o.picture&&!imgs.find(i => i[0]?.[0] == origImg))imgs.push(origImg);\n});\n\n// gallery\nlet mediaInfo;\ntry {\n mediaInfo = JSON.parse($._.match(/>({\"widgets\":{\"@MarketNode\\/UgcMediaGallery\".+?})<\\//)?.[1]);\n} catch (error) {}\n\n// reviews\nif (mediaInfo?.collections?.review) {\n for (const r of Object.values(mediaInfo.collections.review).reverse()) {\n r.photos.forEach(p => {\n const text = ['⭐' + r.averageGrade];\n if (r.comment) text.push(r.comment);\n if (r.pro) text.push('👍🏻 ' + r.pro);\n if (r.contra) text.push('👎🏻 ' + r.contra);\n if (r.created) text.push(new Date(r.created).toISOString().substring(0,10))\n imgs.push([`https://avatars.mds.yandex.net/get-${p.namespace}/${p.groupId}/${p.imageName}/orig`, text.join(' | ')]);\n })\n }\n}\n\nlet userImgs = [...page.querySelectorAll('[data-zone-name=\"ugc-media-gallery\"] img')].map(i => i.src.replace(/\\/\\d+x\\d+$/, '/orig'));\nfor (const ui of userImgs) {\n if (!imgs.find(i => i[0] == ui)) {\n imgs.push([ui, 'User Image']);\n }\n}\n\n// videos\nif (mediaInfo?.collections?.ugcvideo) {\n let vidInfo = Object.values(mediaInfo?.collections?.ugcvideo);\n for (const img of imgs) {\n // let id = i[0].match(/\\/get-vh\\/\\d+\\/(\\w+)\\//)?.[1];\n if (!img[0].includes('/get-vh/')) continue;\n let info = vidInfo.find(v => v.metaInfo?.thumbnail == img[0]);\n if (!info) continue;\n hasVideo = true;\n img[1] = `<imagus-extension type=\"videojs\" url=\"${info.metaInfo.streamUrl}\"></imagus-extension>${info.title}`;\n img[0] = '';\n }\n}\n\nif (hasVideo) {\n this.TRG.IMGS_ext_data = imgs;\n return { loop: 'imagus://extension' };\n}\n\nreturn imgs;","img":"^mdata\\.yandex\\.[^/]+/i\\?path=[^/]+\\.(?:jpe?g|png|gif|bmp)$","note":"hababr + Imagus_fan (edit)\nhttps://www.reddit.com/r/imagus/comments/z0zyox/comment/lw25occ\nOLD\nhttps://forum.ru-board.com/topic.cgi?forum=5&topic=50874&start=2820#16\nhttps://www.reddit.com/r/imagus/comments/z0zyox/comment/lnv1onq\nhttps://www.reddit.com/r/imagus/comments/18n32dx/comment/kebeozx\n\n!!!\n- Есть показ фото и видео покупателей.\n- Курсор следует наводить на название или на весь блок с описанием товара.\n\nПРИМЕРЫ\nhttps://market.yandex.ru/catalog--televizory/26960210\nhttps://market.yandex.ru/product--pylesos-kitfort-kt-509/12349421/reviews?cpa=1&uniqueId=920840\nhttps://market.yandex.ru/catalog--planshety/54545\nвнешние ссылки:\nhttps://forum.ru-board.com/topic.cgi?forum=5&topic=50874&start=1360#11"}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement