// ==UserScript==
// @name Загрузка скринов из раздачи для pornolab.net
// @description Загрузка скринов из раздачи
// @namespace memmes
// @include *://*pornolab.net/forum/tracker.php*
// @version 2.2
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_xmlhttpRequest
// @grant GM_openInTab
// ==/UserScript==
var FullLoad = true;
var debag = false;
var LoadImage = "data:image/gif;base64,R0lGODlhIAAZAOMAAKyqrNTS1Ly6vOzq7LSytOTi5MTCxKyurNTW1Ly+vPT29LS2tP///wAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQJCQAMACwAAAAAIAAZAAAEyZDJSau9OOvNu/9geB0AeRjSYJaIhJTwICXHCiQCnkjFoRMBSWCRExxkDFwRcBMIFjvGgPALMoa5BAHpzDIT4FzKl1tYsbjjDJpjOnXjqpCYRuraNxw0ngPOswQFM28CbkpRKjpmf3WDS00Je1JkWmd0RnZsCV9FiJR+V3RadoSckZ6KlkVqDE9hpmKTcqGrpF6Qkol9qmCBjjiwqGW8mL+FJQQEPikAycpnB84AdtHKAAjY2IIMCtnYSAPeCAo84iLn6Onq6+wdEQAh+QQJCQAVACwAAAAAIAAZAIQEAgSsqqzU0tQ0NjS8urwMDgzs6uy0srREQkQMCgzk4uTEwsQEBgSsrqzU1tQ8Pjy8vrwUEhT09vS0trRERkT///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAF6CAQFSNSnWiqripDvY/JznSVvBTy1Lx6w7JezwUUCn+U2MnQCDQbjpPDSTWcII1nAKmsMAkQwkRwEkzAhIa1EkYHiEnZNzwunyGQw5rAD29xXXNiZBVmaGpXE2EQf0VeDWh1hXdpa4tgjXFLkHSEhngHCld9BG+AcpyDdoeWpJmBqZKflYmLr6iRnnd5rW5cuJ2rYYgVYnilcLC5wrRsfYy/m8uTYHmizr6n0sHUw71+0V4BB+QNng3kBwGW6AdNyTISDvPzawb08xInCvgO4UY1/gGcIXDgCgYIEg4IYnAFgIcPdzRkEQIAIfkECQkAHwAsAA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clasoZOvlYqbjUuQoL96sH1amV2qn62Sw1bFcKiqwMtszXOWfpu0ybfCpLF+gNF/gKwCXIB65AUCbgbvBgoP8/OXEAn081kN+Q8JPggCCAwgo6DBgwgTKmwRAgA7";
var MyMas = [];
var loc_hostname = location.hostname;
debug_log(location.hostname);
var RegexString = GetRegexString(loc_hostname);
debug_log(RegexString);
var RegexStringR = "body tbody.row1 header";
var RegexStringS = "body tbody .row1 form";
var body = document.querySelector('body');
body.addEventListener('click', MyFunc);
function GetRegexString(pDom)
{
var result= "";
if (FullLoad)
{
result = /<div class="post_body"([\s\S]*?)<div class="clear"><\/div>/;
}
else
{
result = /((<a href=.*?(?:radikal|fastpic|firepic|you-logo|lostpic|imageban|sendpic|picclick|imagevenue|turboimagehost).*?<\/a>))/g;
}
return result;
}
function MySpl(event) //костыль для спойлеров
{
var EventTarget = event.target;
if (/sp-head/.test(EventTarget.className))
{
var Spl = EventTarget.parentNode;
if (/sp-wrap/.test(Spl.className))
{
var Blck = Spl.querySelector('div:nth-child(2)');
if (Blck.style.display == "block")
{
Blck.style.display = "none";
} else Blck.style.display = "block";
}
}
}
function GetCellHREF(pDom,Cell2)
{
var result = Cell2.querySelector('a:nth-child(1)').href;
debug_log(result);
return result;
}
function PrepareHTML(pDom,HTMLtext)
{
var result = HTMLtext;
if (FullLoad)
{
debug_log("PreparePost");
result = PreparePost(pDom,HTMLtext);
} else
{
debug_log("PrepareImage");
result = PrepareImage(pDom,HTMLtext);
}
return result;
}
function PreparePost(pDom,HTMLtext)
{
var result = HTMLtext;
result = result.replace(new RegExp('<div class="clear"([\s\S]*)<\/div>"', 'g'),'');
result = result.replace(new RegExp('var class="postImg postImgAligned img-right" title', 'g'),'img src');
result = result.replace(new RegExp('var class="postImg" title', 'g'),'img src');
result = result.replace(new RegExp('</var>', 'g'),'</br>');
result = result.replace(new RegExp('<div class="sp-wrap">', 'g'),'<div class="sp-wrap"><div class="sp-head folded clickable">Спойлер</div>');
return result;
}
function PrepareImage(pDom,HTMLtext)
{
var result = HTMLtext;
result = result.replace(new RegExp('class="postLink"', 'g'),'');
result = result.replace(new RegExp('var class="postImg" title', 'g'),'img src');
result = result.replace(new RegExp('</var>', 'g'),'');
return result;
}
function ItsLine(target)
{
var result = false;
debug_log(target.className);
result = (target.className == "row4 med tLeft u");
return result;
}
function AlreadyLoad(target){return (target.hasAttribute('MyLoad')===false);}
function DomDell(pLink){return pLink.replace(/^.*?:\/\/.*?(?=\/|$)/,'');}
function scrollToElement(theElement)
{
var selectedPosX = 0;var selectedPosY = 0;
while (theElement != null)
{
selectedPosX += theElement.offsetLeft;selectedPosY += theElement.offsetTop;theElement = theElement.offsetParent;
}
window.scrollTo(selectedPosX,selectedPosY);
}
function debug_log(pLogText){if(debag){console.log(pLogText);}}
function ItsMyDel(target) {return (target.hasAttribute('MyDel'));}
function AddTable(target)
{
var RandomNom = 1;//random(9999);
target.setAttribute('MyLoad', RandomNom);
var mytbl = document.createElement('table');
mytbl.style.width = '100%';
mytbl.setAttribute('MyTable', 'true');
var mytbdy = document.createElement('tbody');
mytbl.setAttribute('border', '0');
var tr = document.createElement('tr');
var td = document.createElement('td');
td.style.width = '1%';
//td.innerHTML = "<b>с</br>в</br>е</br>р</br>н</br>у</br>т</br>ь</b>";
td.style.backgroundColor = "gray";
td.style.cursor= "pointer";
td.setAttribute('MyDel', 'true');
// td.setAttribute('ScrolTo', RandomNom);
tr.appendChild(td);
var Result_td = document.createElement('td');
var LImg = new Image();
LImg.setAttribute('src', LoadImage);
LImg.setAttribute('style', "display: block; margin: 0 auto;");
Result_td.appendChild(LImg);
tr.appendChild(Result_td);
td = document.createElement('td');
td.style.width = '1%';
//td.innerHTML = "<b>с</br>в</br>е</br>р</br>н</br>у</br>т</br>ь</b>";
td.style.backgroundColor = "gray";
td.style.cursor= "pointer";
tr.appendChild(td);
td.setAttribute('MyDel', 'true');
// td.setAttribute('ScrolTo', RandomNom);
mytbdy.appendChild(tr);
tr = document.createElement('tr');
td = document.createElement('td');
td.style.width = '1%';
td.style.backgroundColor = "gray";
td.style.cursor= "pointer";
td.setAttribute('MyDel', 'true');
// td.setAttribute('ScrolTo', RandomNom);
tr.appendChild(td);
td = document.createElement('td');
// td.style.width = '1%';
td.innerHTML = "<center><b>свернуть</b></center>";
td.style.backgroundColor = "gray";
td.style.cursor= "pointer";
td.setAttribute('MyDel', 'true');
// td.setAttribute('ScrolTo', RandomNom);
tr.appendChild(td);
td = document.createElement('td');
td.style.width = '1%';
td.style.backgroundColor = "gray";
td.style.cursor= "pointer";
td.setAttribute('MyDel', 'true');
//td.setAttribute('ScrolTo', RandomNom);
tr.appendChild(td);
mytbdy.appendChild(tr);
mytbl.appendChild(mytbdy);
target.appendChild(mytbl);
return Result_td;
}
function GetMyTable(EventTarget)
{
result = EventTarget;
while ((result.hasAttribute('MyTable') === false)&&(result.tagName != 'BODY'))
{
result = result.parentNode;
}
return result;
}
function MyFunc(event)
{
EventTarget = event.target;
debug_log("--event.target--");
debug_log(EventTarget);
if (EventTarget.parentNode.className == "row4 med tLeft u")
{
EventTarget = EventTarget.parentNode;
}
if (ItsLine(EventTarget))
{
debug_log("--TARGET--");
if (AlreadyLoad(EventTarget))
{
debug_log("--Cell--");
debug_log(EventTarget);
debug_log("--AddTable--");
var ResTd = AddTable(EventTarget);
ResTd.addEventListener('click', MySpl);
MyMas.push(EventTarget);
CellHREF = GetCellHREF(loc_hostname,EventTarget);
debug_log("--HREF--");
debug_log(CellHREF);
MdownloadPage(CellHREF);
}else
{
console.log("UN LOAD");
var MyTable = EventTarget.querySelector("table[MyTable]");
EventTarget.removeAttribute('MyLoad');
MyTable.remove();
}
}
//клик по ячейкам свернуть
if (ItsMyDel(EventTarget)||ItsMyDel(EventTarget.parentNode))
{
var MyTable = GetMyTable(EventTarget);
if (MyTable!=EventTarget)
{
var Cell = MyTable.parentNode;
Cell.removeAttribute('MyLoad');
//Cell
// if (!(document.scrollTop() + window.height() > Cell.offset().top && document.scrollTop() - Cell.offset().top < Cell.height()))
// {
// scrollToElement(Cell);
// }
MyTable.remove();
}
console.log("MyDELLL");
}
}
function MdownloadPage(url)
{
debug_log("url");
debug_log(url);
var data = GM_xmlhttpRequest({
method: 'GET',
url: url,
headers: {
'User-Agent': 'Mozilla/5.0',
'Accept': 'text/xml'
},
onload: function (response) {
debug_log("response");
debug_log(response);
debug_log("response.finalUr");
debug_log(response.finalUrl);
debug_log("MyMas");
debug_log(MyMas);
for (var em = 0; em < MyMas.length; em++)
{
if (DomDell(GetCellHREF(loc_hostname,MyMas[em]))==DomDell(response.finalUrl)){
TargetEm = MyMas[em];
MyMas.splice(em, 1);
break;
}
}
debug_log("TargetEm");
debug_log(TargetEm);
LoadDIV = TargetEm.querySelector('table[MyTable] > tbody > tr > td:nth-child(2)');
while (LoadDIV.lastChild) LoadDIV.removeChild(LoadDIV.lastChild);
debug_log("LoadDIV");
debug_log(LoadDIV);
var m = RegexString.exec(response.responseText);
debug_log("---m---");
debug_log(m);
if (m !== null)
{
debug_log("---m[0]---");
debug_log(m[0]);
res = PrepareHTML(loc_hostname,m[0]);
debug_log(res);
LoadDIV.innerHTML += res;
}
}
});
}