kenko2

Silver Member | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору destiny_child hababr Возвращаемся к вопросу о фильтре для Рутрекера/Порнолаба (внешние ссылки на раздачи). Ниже почти рабочая версия от Imagus_fan. Охватывает только основные хостинги (Fastpic, ImageBan, ImageBam, Imgbox, ImageVenue, TurboImageHost), но это в целом 90% раздач. Возможны ошибки с учетом того, что оформление раздач на трекерах, особенно на Pornolab, это полный колхоз. Нужно также правило для SMH (+ возможно еще правило SMH которое сделал hababr для Fastpic). В общем читаем примечания к фильтру. Спасибо всем кто принял участие. Код: {"RuTracker+Pornolab-p":{"link":"^(?:rutracker\\.org|pornolab\\.net)/forum/viewtopic\\.php(?!.+&).+","res":":\nconst that = this, find = this.find, poster = [...$._.matchAll(/(?:\"postImg postImgAligned img-right\"|<div class=\"post-align\" style=\"text-align: center;\"[^\\n]+?) title=\"([^\"]+)/g)].pop()?.[1], linksSrc = $._.match(/<(?:div class=\"sp-head folded\"><span|h3 class=\"sp-title\")>.{0,650}<a href=\"http[^\"]+\" class=\"postLink\"><var class=\"postImg\".+?<!--\\/post_body-->/s)?.[0], links = linksSrc ? [...linksSrc.matchAll(/<a href=\"(http[^\"]+)\" class=\"postLink\"><var class=\"postImg\" title=\"([^\"]+)/g)].map(i => [i[1], i[2]]) : [];\n\n// Function parses image page source for full size image\nfunction getImg(url, src) {\n let img, thumbnail = url[1];\n url = url[0];\n\n // Test the links for which site it is and try to get the full size image\n if(url.includes('imageban.ru/'))img = src.match(/data-original=\"([^\"]+)/)?.[1];\n else if(url.includes('fastpic.org/'))img = src.match(/<img src=\"([^\"]+)\" class=\"image img-fluid\"/)?.[1];\n else if(url.includes('imagevenue.com/'))img = src.match(/img src=\"([^\"]+)\" id=\"main-image\"/)?.[1];\n\n // If full size image not found or site not supported, get the default page image\n else img = src.match(/property=\"og:image\" content=\"([^\"]+)/)?.[1];\n\n // If no matches, URL might be an image\n if(!img)img = url;\n return [[img, thumbnail], url];\n}\n\n// Function uses asynchronous XMLHttpRequest to get image page\nconst getImgSource = url => new Promise(resolve => {\n\n // If the full size image can be created by another sieve, use it instead\n const imgUpgrade = find({src: url[1]});\n if (imgUpgrade && imgUpgrade !== url[1]){\n resolve([imgUpgrade, url[1]]);\n } else {\n // Get image link page source\n if (location.protocol === 'https:') url[0] = url[0].replace(/^http:/, 'https:');\n const x = new XMLHttpRequest();\n // #rutracker_header added to match SMH rules\n x.open('GET', url[0] + '#rutracker_header');\n x.onload = () => resolve(getImg(url, x.responseText));\n x.onerror = () => resolve('');\n x.send();\n }\n})\n\n// Get images asynchronously and then create album\nPromise.all(links.map(getImgSource)).then(album=>{\n album = album.filter(Boolean);\n if(poster)album.unshift([poster]);\n that.TRG.IMGS_album = $[0];\n that.stack[$[0]] = album;\n that.stack[$[0]].unshift(1);\n that.album(0);\n});\nreturn null","note":"Imagus_fan\nhttps://www.reddit.com/r/imagus/comments/z0zyox/comment/myz92hh\nOLD\nhttp://forum.ru-board.com/topic.cgi?forum=5&topic=50874&start=1600#9\n\n\n!!!\n- показывает постер + скриншоты при наведении на название раздачи на форуме;\n- для работы данного фильтра необходимо расширение SMH (см.ЧаВо, п.12);\n- в начале на пару секунд фильтр показывает желтый спиннер, это нормально;\n- иногда (редко) требуется повторное наведение курсора;\n- фильтр поддерживает только наиболее крупные хостинги (90% раздач) - в остальных случаях он будет выдавать ошибку;\n\n\nПРИМЕРЫ\nhttp://forum.ru-board.com/topic.cgi?forum=5&topic=50874&start=1360#11"}} | SMH rule: Код: {"format_version":"1.2","target_page":"","headers":[{"url_contains":"#rutracker_header","action":"add","header_name":"Access-Control-Allow-Origin","header_value":"*","comment":"","apply_on":"res","status":"on"}],"debug_mode":false,"show_comments":true,"use_url_contains":true} |
| Всего записей: 4700 | Зарегистр. 10-11-2005 | Отправлено: 14:10 21-06-2025 | Исправлено: kenko2, 16:07 21-06-2025 |
|