hababr
Junior Member | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору greeple Вот чуть изменил код, чтобы без прокси работало: Код: {"TEST__RuTracker|Pornolab-p":{"link":"(rutracker\\.org|pornolab.net)/forum/viewtopic\\.php(?!.+&).+","res":":\ndebugger;\nlet res = [];\n// вытащим одну большую постерину-баннер со страницы\nlet re = /class=\\\"postImg postImgAligned img-right\\\".+?=\\\"([^\\\"]+)/gi;\nlet a = re.exec($._);\nif (a) {\n\tif (a[1].includes(\"ipicture.ru\") ||\n\t\ta[1].includes(\"tinypic.com\") ||\n\t\ta[1].includes(\"imageshack.us\") ||\n\t\ta[1].includes(\"10pix.ru\") ||\n\t\ta[1].includes(\"imgur.com\") ||\n\t\ta[1].includes(\"photobucket.com\") ||\n\t\ta[1].includes(\"radikal.ru\") ||\n\t\ta[1].includes(\"vfl.ru\") ||\n\t\ta[1].includes(\"lostpic.tk\")) {\n\t\tres.push([\"https://static.t-ru.org/smiles/tr_oops.gif\"]);\n\t} else {\n\t\tres.push([a[1]]); // она и будет первым объектом для показа\n\t}\n} else return null;\n\n// Извлечение основного блока\nconst mainContent = $._;\nconst startMarker = '<span>Скриншоты</span></div>';\nconst endMarker = '</div>';\nconst contentBlock = (mainContent.split(startMarker)[1] || '').split(endMarker)[0] || '';\n\n// Парсинг ссылок\nconst parser = new DOMParser();\nconst doc = parser.parseFromString(contentBlock, 'text/html');\nconst links = Array.from(doc.querySelectorAll('a'));\n\n// Синхронная обработка ссылок\nfor (const link of links) {\n\ttry {\n\t\tif (link.href.includes(\"ipicture.ru\") ||\n\t\t\tlink.href.includes(\"tinypic.com\") ||\n\t\t\tlink.href.includes(\"imageshack.us\") ||\n\t\t\tlink.href.includes(\"10pix.ru\") ||\n\t\t\tlink.href.includes(\"imgur.com\") ||\n\t\t\tlink.href.includes(\"photobucket.com\") ||\n\t\t\tlink.href.includes(\"radikal.ru\") ||\n\t\t\tlink.href.includes(\"vfl.ru\") ||\n\t\t\tlink.href.includes(\"lostpic.tk\")) {\n\t\t\tres.push([\"https://static.t-ru.org/smiles/tr_oops.gif\"]);\n\t\t} else {\n\t\t\tif (!link.href.includes(\"fastpic.\")) // пока вытаскивать FullImage будем лишь с него\n\t\t\t\tres.push([link.href])\n\t\t\telse {\n\t\t\t\t// Формируем URL для прокси. Нам надо же БОЛЬШОЕ оригинальное фото скриншота, поэтому ...\n\t\t\t\tconst regex = /i(\\d+)\\.fastpic\\.(ru|org)\\/(?:thumb|big)\\/(\\d{2,4}\\/\\d{2,4})\\/[\\da-f]{2}(\\/.+)$/;\n\t\t\t\tconst match = link.href.match(regex);\n\t\t\t\tif (match) {\n\t\t\t\t\t// ... мы формируем новую ссылку по правилу:\n\t\t\t\t\tlet url = `https://fastpic.${match[2]}/fullview/${match[1]}/${match[3]}${match[4]}`;\n\n\t\t\t\t\tconst encoded = encodeURIComponent(url);\n\t\t\t\t\tconst proxyUrl = `https://api.allorigins.win/get?url=${encoded}`;\n\t\t\t\t\t// Синхронный XHR\n\t\t\t\t\tconst xhr = new XMLHttpRequest();\n\t\t\t\t\t// xhr.open('GET', proxyUrl, false); // false = синхронный режим\n\t\t\t\t\txhr.open('GET', url, false); // false = синхронный режим\n\t\t\t\t\txhr.send();\n\n\t\t\t\t\tif (xhr.status !== 200) continue;\n\n\t\t\t\t\t// Парсинг ответа\n\t\t\t\t\t// const data = JSON.parse(xhr.responseText);\n\t\t\t\t\t// const cleanHtml = data.contents.replace(/\\s+/g, '');\n\t\t\t\t\tconst cleanHtml = xhr.responseText.replace(/\\s+/g, '');\n\n\t\t\t\t\t// Извлечение URL\n\t\t\t\t\tconst imgMatch = cleanHtml.match(/varloading_img='(.*?)(?=')/i);\n\t\t\t\t\tif (!imgMatch) continue;\n\n\t\t\t\t\turl = imgMatch[1];\n\t\t\t\t\tif (typeof url === 'string' && url.startsWith('http')) {\n\t\t\t\t\t\tres.push([url]);\n\t\t\t\t\t}\n\t\t\t\t} else\n\t\t\t\t\tres.push([link.href]);\n\t\t\t}\n\t\t}\n\t} catch (e) {\n\t\tconsole.debug('Ошибка обработки:', link.href, e.message);\n\t}\n}\n\n// Вывод результата только после всей обработки\nconsole.log(res);\n\nreturn res;","note":"destiny child\nhttp://forum.ru-board.com/topic.cgi?forum=5&topic=50874&start=1600#9\n\n\n!!!\nТолько для внешних ссылок. Показывает постер + миниатюры скриншотов.\n==\nOnly for external links. Shows the poster + thumbnails of screenshots.\n\n\nПРИМЕРЫ\nhttp://forum.ru-board.com/topic.cgi?forum=5&topic=50874&start=1360#11"}} | Вот это правило для SimpleModifyHeaders: Код: fastpic.org/fullview Add Access-Control-Allow-Origin * fastpic Response | | Всего записей: 161 | Зарегистр. 21-07-2014 | Отправлено: 17:16 15-05-2025 | Исправлено: hababr, 17:16 15-05-2025 |
|