// ==UserScript==
// @name Filmweb.pl eksport ocen (wersja poprawiona)
// @namespace kapela86
// @description Skrypt pozwala na eksport ocen oraz chcę/nie chcę zobaczyć/zagrać do plików xls. Działa na własnym profilu oraz znajomych.
// @match *://filmweb.pl/user/*
// @match *://www.filmweb.pl/user/*
// @version 1.8
// @grant none
// @license GPL-3.0-or-later
// @run-at document-idle
// ==/UserScript==
"use strict";
/*
Changelog:
1.0 2015-04-14 pierwsze wydanie
1.1 2015-04-14 tytuły oryginalne są teraz klikalne i kierują do danego tytułu na stronie filmwebu
1.2 2015-04-21 dodano pobieranie komentarzy do ocen
1.3 2015-04-26 dodano pobieranie chcę/nie chcę zobaczyć/zagrać
1.4 2015-05-03 dodano pobieranie list znajomych
1.4.1 2015-05-04 różne drobne poprawki i optymalizacje kodu
1.4.2 2015-05-28 drobna poprawka dla osób mających spację w nicku
1.4.3 2016-11-27 poprawka dla osób które zainstalowały skrypt po 2016-10-04 i nie działał im przycisk zapisu do XLS
1.4.4 2017-07-09 naprawienie pobierania list "Chcę zobaczyć" (filmweb dodał kolumnę z datą dodania i to psuło wykonywanie skryptu)
1.5 2018-04-18 poprawienie skryptu aby mógł działać z nową wersją wyglądu profili i list ocen (na razie tylko pobieranie ocen zrobione)
1.6 2018-05-06 dodanie pobierania ocen programów tv i list "chcę zobaczyć/zagrać"
1.7 2018-05-27 dodanie pobierania list "nie interesuje mnie"
1.7.1 2018-05-29 poprawka dla nowego wyglądu strony profili
1.7.2 2018-07-22 poprawka drobnego błędu przy pobieraniu ocen
1.7.3 2019-04-14 poprawiłem błąd związany z nieładowaniem się skryptu i nieprawidłowym generowaniem odnośników do strony filmweb dla tytułów
1.7.4 2020-05-06 poprawilem błąd z brakiem polskich tytułów i roku produkcji (filmweb wprowadził drobne zmiany w kodzie strony); dodatkowo teraz kolumna z oryginalnym tytułem nie będzie pusta w sytuacji gdy jest on taki sam jak polski
1.7.5 2020-05-17 poprawilem błąd z niewyświetlaniem się panelu pobierania ocen (filmweb znowu wprowadził drobne zmiany w kodzie strony)
1.7.6 2021-09-19 tymczasowe obejście zmiań wprowadzonych w kodzie strony
1.7.7 poprawki na zmiany w kodzie strony filmwebu i sposobie pobierania ocen
1.8 2022-11-15 poprawki dodane przez @tomfilmowiec, poprawione pobieranie danych (filmweb wprowdził drobne zmiany w kodzie strony), poprawione pobieranie ocen (teraz pobiera z osobnych requestów), dodane opóźnienia czasowe, poprawki kosmetyczne
To do:
- kompatybilność z greasemonkey 4
- https://www.w3schools.com/howto/howto_js_progressbar.asp
- dogadać się z Grzegorz_Derebecki z FDB odnośnie nowych kolumn/formatu
- naprawić "w przypadku gdy polski tytuł jest taki sam jak oryginalny wtedy w kolumnie tytuł oryginalny zostawia puste pole."
- ogarnąć kwestię gdy ktoś nie ma ocen w danej kategorii lub nie mamy uprawnień do przeglądania ocen
- eksport ocen przy eksporcie listy chcę/nie chcę zobaczyć/zagrać
- eksport ocen aktorów
- eksport obejrzanych odcinków seriali wraz z ocenami
- przetestować ExcellentExport.js v3.x (eksport do xlsx, wiele arkuszy w pliku)
- sprawdzić czy da się też eksportować komentarze innych osób do naszej oceny
*/
/*
ExcellentExport.js v1.5
https://github.com/jmaister/excellentexport
https://raw.githubusercontent.com/jmaister/excellentexport/v1.5/excellentexport.min.js
*/
var n=String.fromCharCode,p;a:{try{document.createElement("$")}catch(q){p=q;break a}p=void 0} window.btoa||(window.btoa=function(b){for(var g,c,f,h,e,a,d=0,r=b.length,s=Math.max,l="";d<r;){g=b.charCodeAt(d++)||0;c=b.charCodeAt(d++)||0;a=b.charCodeAt(d++)||0;if(255<s(g,c,a))throw p;f=g>>2&63;g=(g&3)<<4|c>>4&15;h=(c&15)<<2|a>>6&3;e=a&63;c?a||(e=64):h=e=64;l+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(f)+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(g)+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(h)+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(e)}return l}); window.atob||(window.atob=function(b){b=b.replace(/=+$/,"");var g,c,f,h,e=0,a=b.length,d=[];if(1===a%4)throw p;for(;e<a;)g="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(b.charAt(e++)),c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(b.charAt(e++)),f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(b.charAt(e++)),h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(b.charAt(e++)),g=(g&63)<< 2|c>>4&3,c=(c&15)<<4|f>>2&15,f=(f&3)<<6|h&63,d.push(n(g)),c&&d.push(n(c)),f&&d.push(n(f));return d.join("")});
var ExcellentExport=function(){function b(e,a){return e.replace(RegExp("{(\\w+)}","g"),function(d,e){return a[e]})}var g={excel:"data:application/vnd.ms-excel;base64,",csv:"data:application/csv;base64,"},c={excel:'<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">\x3c!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--\x3e</head><body><table>{table}</table></body></html>'},f= ",",h="\r\n";return{excel:function(e,a,d){a=a.nodeType?a:document.getElementById(a);var f=g.excel;a=b(c.excel,{a:d||"Worksheet",table:a.innerHTML});a=window.btoa(window.unescape(encodeURIComponent(a)));e.href=f+a;return!0},csv:function(e,a,d,b){void 0!==d&&d&&(f=d);void 0!==b&&b&&(h=b);a=a.nodeType?a:document.getElementById(a);var c="",l,k;for(d=0;d<a.rows.length;d++){l=a.rows[d];for(b=0;b<l.cells.length;b++){k=l.cells[b];var c=c+(b?f:""),m=k.textContent.trim();k=m;var t=-1!==m.indexOf(f)||-1!==m.indexOf("\r")|| -1!==m.indexOf("\n");(m=-1!==m.indexOf('"'))&&(k=k.replace(/"/g,'""'));if(t||m)k='"'+k+'"';c+=k}c+=h}a=g.csv+window.btoa(window.unescape(encodeURIComponent(c)));e.href=a;return!0}}}();
setTimeout(function()
{
if (typeof window.IRI == "undefined") return;
var NaszeID = window.IRI.globals.user.id.toString();
var IDWyswietlanegoUsera = document.querySelector("div.userPreview").getAttribute("data-id");
//var CzyZnajomy = Boolean(window.IRI.deprecatedUser.connections[IDWyswietlanegoUsera]);
var NazwaProfilu = document.querySelector("div.userPreview").getAttribute("data-name");
var OpoznieniePobraniaStrony = 500;
//debug
//var CzyZnajomy = false, IDWyswietlanegoUsera = "1519176", NaszeID = "1519176", NazwaProfilu = "Kapela86";
//debug
//if ((CzyZnajomy || IDWyswietlanegoUsera === NaszeID) && window.location.pathname === "/user/"+NazwaProfilu.split(" ").join("+"))
if (window.location.pathname === "/user/"+NazwaProfilu.split(" ").join("+"))
{
var UserDescriptionSectionHeader = document.querySelector("section.userDescriptionSection header.userDescriptionSection__header");
var KtoraStronaDoPobrania = 0;
var IleStronZOcenami = 1;//wartość tutaj nie ma znaczenia bo później jest ładowana poprawna z kodu strony, ważne żeby tutaj była większa niż 0
var KtoreElementy, NumerDiva, NumerPrzycisku, Tabela, RowSelector, CellSelector, IloscOcen, IloscPobranychOcen, filmNode, TempString, TempArray, TempNode, TempObject;
var TablicaDivow = [
{selektor: "EksportOcen_DivOceny", id: "eksportocen", tytul: "pobierz oceny:"},
{selektor: "EksportOcen_DivChcęZobaczyć", id: "eksportchce", tytul: "pobierz \"chcę zobaczyć/zagrać\":"},
{selektor: "EksportOcen_DivNieChcęZobaczyć", id: "eksportnieinteresuje", tytul: "pobierz \"nie interesuje mnie\":"}
];
var TablicaPrzyciskow = [
[
{selektor: "EksportOcen_PrzyciskPobierzOcenyFilmow", tytul: "filmy", tytul_fw: "film", id: "0,0", ktoreelementy: "id,tytulPL,tytulORG,rokprod,ulubione,ocena,komentarz,gatunek,data", parametr: "films?page=", plik: " - oceny - filmy.xls"},
{selektor: "EksportOcen_PrzyciskPobierzOcenySeriali", tytul: "seriale", tytul_fw: "serial", id: "0,1", ktoreelementy: "id,tytulPL,tytulORG,rokprod,ulubione,ocena,komentarz,gatunek,data", parametr: "serials?page=", plik: " - oceny - seriale.xls"},
{selektor: "EksportOcen_PrzyciskPobierzOcenyGier", tytul: "gry", tytul_fw: "videogame", id: "0,2", ktoreelementy: "id,tytulPL,tytulORG,rokprod,ulubione,ocena,komentarz,gatunek,data", parametr: "games?page=", plik: " - oceny - gry.xls"},
{selektor: "EksportOcen_PrzyciskPobierzOcenyProgramowTV", tytul: "programy tv", tytul_fw: "tvshow", id: "0,3", ktoreelementy: "id,tytulPL,tytulORG,rokprod,ulubione,ocena,komentarz,gatunek,data", parametr: "tvshows?page=", plik: " - oceny - programy tv.xls"},
{selektor: "EksportOcen_PrzyciskZapiszOcenyDoXLS", tytul: "zapisz do XLS", id: "zapisocen"}
],
[
{selektor: "EksportOcen_PrzyciskPobierzChceZobaczycFilmy", tytul: "filmy", tytul_fw: "film", id: "1,0", ktoreelementy: "id,tytulPL,tytulORG,rokprod,jakbardzo,gatunek", parametr: "wantToSee?filmType=FILM&page=", plik: " - chcę zobaczyć - filmy.xls"},
{selektor: "EksportOcen_PrzyciskPobierzChceZobaczycSeriale", tytul: "seriale", tytul_fw: "serial", id: "1,1", ktoreelementy: "id,tytulPL,tytulORG,rokprod,jakbardzo,gatunek", parametr: "wantToSee?filmType=SERIAL&page=", plik: " - chcę zobaczyć - seriale.xls"},
{selektor: "EksportOcen_PrzyciskPobierzChceZagrac", tytul: "gry", tytul_fw: "videogame", id: "1,2", ktoreelementy: "id,tytulPL,tytulORG,rokprod,jakbardzo,gatunek", parametr: "wantToPlay?page=", plik: " - chcę zagrać.xls"},
{selektor: "EksportOcen_PrzyciskPobierzChceZobaczycProgramyTV", tytul: "programy tv", tytul_fw: "tvshow", id: "1,3", ktoreelementy: "id,tytulPL,tytulORG,rokprod,jakbardzo,gatunek", parametr: "wantToSee?filmType=TV_SHOW&page=", plik: " - chcę zobaczyć - programy tv.xls"},
{selektor: "EksportOcen_PrzyciskZapiszChceZobaczycDoXLS", tytul: "zapisz do XLS", id: "zapischce"}
],
[
{selektor: "EksportOcen_PrzyciskPobierzNieInteresujeFilmy", tytul: "filmy", tytul_fw: "film", id: "2,0", ktoreelementy: "id,tytulPL,tytulORG,rokprod,gatunek", parametr: "dontWantToSee?filmType=FILM&page=", plik: " - nie interesuje - filmy.xls"},
{selektor: "EksportOcen_PrzyciskPobierzNieInteresujeSeriale", tytul: "seriale", tytul_fw: "serial", id: "2,1", ktoreelementy: "id,tytulPL,tytulORG,rokprod,gatunek", parametr: "dontWantToSee?filmType=SERIAL&page=", plik: " - nie interesuje - seriale.xls"},
{selektor: "EksportOcen_PrzyciskPobierzNieInteresujeGry", tytul: "gry", tytul_fw: "videogame", id: "2,2", ktoreelementy: "id,tytulPL,tytulORG,rokprod,gatunek", parametr: "dontWantToSee?filmType=VIDEOGAME&page=", plik: " - nie interesuje - gry.xls"},
{selektor: "EksportOcen_PrzyciskPobierzNieInteresujeProgramyTV", tytul: "programy tv", tytul_fw: "tvshow", id: "2,3", ktoreelementy: "id,tytulPL,tytulORG,rokprod,gatunek", parametr: "dontWantToSee?filmType=TV_SHOW&page=", plik: " - nie interesuje - programy tv.xls"},
{selektor: "EksportOcen_PrzyciskZapiszNieInteresujeDoXLS", tytul: "zapisz do XLS", id: "zapisnieinteresuje"}
]
];
var ListaKolumn = {
id: {
NaglowekTabeli: "ID",
CzyDodac: false
},
tytulPL: {
NaglowekTabeli: "Tytuł polski",
CzyDodac: false
},
tytulORG: {
NaglowekTabeli: "Tytuł oryginalny",
CzyDodac: false
},
rokprod: {
NaglowekTabeli: "Rok produkcji",
CzyDodac: false
},
jakbardzo: {
NaglowekTabeli: "Jak bardzo chcę",
CzyDodac: false
},
ulubione: {
NaglowekTabeli: "Ulubione",
CzyDodac: false
},
ocena: {
NaglowekTabeli: "Ocena",
CzyDodac: false
},
komentarz: {
NaglowekTabeli: "Komentarz",
CzyDodac: false
},
gatunek: {
NaglowekTabeli: "Gatunek",
CzyDodac: false
},
data: {
NaglowekTabeli: "Data",
CzyDodac: false
}
}
var GlownyDiv = document.createElement("div");
GlownyDiv.id = "glownydiv"
GlownyDiv.style.display = "table";
GlownyDiv.style.borderCollapse = "collapse";
GlownyDiv.style.width = "100%";
if (UserDescriptionSectionHeader.querySelector("div#glownydiv") !== null)
{
UserDescriptionSectionHeader.removeChild(UserDescriptionSectionHeader.querySelector("div#glownydiv"));
}
UserDescriptionSectionHeader.insertBefore(GlownyDiv, UserDescriptionSectionHeader.firstChild);
var GlownyDivBody = document.createElement("div");
GlownyDivBody.id = "glownydivbody"
GlownyDivBody.style.display = "table-row-group";
GlownyDiv.appendChild(GlownyDivBody);
for (var i = 0; i < TablicaDivow.length; i++)
{
window[TablicaDivow[i].selektor] = document.createElement("div");
window[TablicaDivow[i].selektor].id = TablicaDivow[i].id;
window[TablicaDivow[i].selektor].style.display = "table-row";
GlownyDiv.appendChild(window[TablicaDivow[i].selektor]);
TempNode = document.createElement("div");
TempNode.style.border = "1px solid";
TempNode.style.display = "table-cell";
TempNode.style.padding = "6px 8px";
TempNode.textContent = TablicaDivow[i].tytul;
window[TablicaDivow[i].selektor].appendChild(TempNode);
for (var j = 0; j < TablicaPrzyciskow[i].length; j++)
{
TempNode = document.createElement("div");
TempNode.style.border = "1px solid";
TempNode.style.display = "table-cell";
TempNode.style.padding = "6px 8px";
window[TablicaDivow[i].selektor].appendChild(TempNode);
window[TablicaPrzyciskow[i][j].selektor] = document.createElement("a");
window[TablicaPrzyciskow[i][j].selektor].style.cursor = "pointer";
//window[TablicaPrzyciskow[i][j].selektor].style.margin = "0px 10px";
TempNode.appendChild(window[TablicaPrzyciskow[i][j].selektor]);
}
}
Reset();
}
function Reset()
{
for (var i = 0; i < TablicaPrzyciskow.length; i++)
{
for (var j = 0; j < TablicaPrzyciskow[i].length; j++)
{
window[TablicaPrzyciskow[i][j].selektor].textContent = TablicaPrzyciskow[i][j].tytul;
window[TablicaPrzyciskow[i][j].selektor].id = TablicaPrzyciskow[i][j].id;
window[TablicaPrzyciskow[i][j].selektor].style.color = "";
if (j < 4)
{
window[TablicaPrzyciskow[i][j].selektor].addEventListener("click", PrzygotowanieDoPobierania, false);
}
else
{
window[TablicaPrzyciskow[i][j].selektor].addEventListener("click", Ostrzezenie, false);
window[TablicaPrzyciskow[i][j].selektor].style.color = "grey";
}
if (j === TablicaPrzyciskow[i].length-1)
{
window[TablicaPrzyciskow[i][j].selektor].removeAttribute("download");
window[TablicaPrzyciskow[i][j].selektor].removeAttribute("href");
}
}
}
TempArray = Object.keys(ListaKolumn);
for (var i = 0; i < TempArray.length; i++)
{
ListaKolumn[TempArray[i]].CzyDodac = false;
}
KtoraStronaDoPobrania = 0;
IleStronZOcenami = 1;
IloscPobranychOcen = 0;
EksportOcen_PrzyciskZapiszOcenyDoXLS.removeEventListener("click", ZapiszOcenyDoXLS, false);
EksportOcen_PrzyciskZapiszChceZobaczycDoXLS.removeEventListener("click", ZapiszChceZobaczycDoXLS, false);
EksportOcen_PrzyciskZapiszNieInteresujeDoXLS.removeEventListener("click", ZapiszNieInteresujeDoXLS, false);
}
function PrzygotowanieDoPobierania()
{
TempArray = this.id.split(",");
NumerDiva = parseInt(TempArray[0]);
NumerPrzycisku = parseInt(TempArray[1]);
Reset();
KtoreElementy = TablicaPrzyciskow[NumerDiva][NumerPrzycisku].ktoreelementy.split(",");
for (var i = 0; i < KtoreElementy.length; i++)
{
ListaKolumn[KtoreElementy[i]].CzyDodac = true;
}
StworzTabelke();
window[TablicaPrzyciskow[NumerDiva][NumerPrzycisku].selektor].textContent = "rozpoczynanie pobierania...";
window[TablicaPrzyciskow[NumerDiva][NumerPrzycisku].selektor].style.color = "darkorange";
if (NumerDiva === 0)
{
PobierzOceny();
}
else if (NumerDiva === 1)
{
PobierzChce();
}
else if (NumerDiva === 2)
{
PobierzNieInteresuje();
}
}
function PobierzOceny()
{
KtoraStronaDoPobrania++;
console.log("Która strona do pobrania: "+KtoraStronaDoPobrania, "z "+IleStronZOcenami);
if (KtoraStronaDoPobrania <= IleStronZOcenami)
{
var Request = new XMLHttpRequest();
Request.onerror = function()
{
window[TablicaPrzyciskow[NumerDiva][NumerPrzycisku].selektor].textContent = "błąd pobierania";
window[TablicaPrzyciskow[NumerDiva][NumerPrzycisku].selektor].style.color = "red";
};
Request.onload = PrzetworzOceny;
Request.open("GET", "//www.filmweb.pl/user/"+NazwaProfilu.split(" ").join("+")+"/"+TablicaPrzyciskow[NumerDiva][NumerPrzycisku].parametr+KtoraStronaDoPobrania, true);
Request.send();
}
else
{
EksportOcen_PrzyciskZapiszOcenyDoXLS.removeEventListener("click", Ostrzezenie, false);
EksportOcen_PrzyciskZapiszOcenyDoXLS.addEventListener("click", ZapiszOcenyDoXLS, false);
EksportOcen_PrzyciskZapiszOcenyDoXLS.setAttribute("download", NazwaProfilu+TablicaPrzyciskow[NumerDiva][NumerPrzycisku].plik);
EksportOcen_PrzyciskZapiszOcenyDoXLS.style.color = "";
KtoraStronaDoPobrania--;
window[TablicaPrzyciskow[NumerDiva][NumerPrzycisku].selektor].style.color = "green";
}
}
function PobierzChce()
{
KtoraStronaDoPobrania++;
console.log("Która strona do pobrania: "+KtoraStronaDoPobrania, "z "+IleStronZOcenami);
if (KtoraStronaDoPobrania <= IleStronZOcenami)
{
var Request = new XMLHttpRequest();
Request.onerror = function()
{
window[TablicaPrzyciskow[NumerDiva][NumerPrzycisku].selektor].textContent = "błąd pobierania";
window[TablicaPrzyciskow[NumerDiva][NumerPrzycisku].selektor].style.color = "red";
};
Request.onload = PrzetworzChce;
Request.open("GET", "//www.filmweb.pl/user/"+NazwaProfilu.split(" ").join("+")+"/"+TablicaPrzyciskow[NumerDiva][NumerPrzycisku].parametr+KtoraStronaDoPobrania, true);
Request.send();
}
else
{
EksportOcen_PrzyciskZapiszChceZobaczycDoXLS.removeEventListener("click", Ostrzezenie, false);
EksportOcen_PrzyciskZapiszChceZobaczycDoXLS.addEventListener("click", ZapiszChceZobaczycDoXLS, false);
EksportOcen_PrzyciskZapiszChceZobaczycDoXLS.setAttribute("download", NazwaProfilu+TablicaPrzyciskow[NumerDiva][NumerPrzycisku].plik);
EksportOcen_PrzyciskZapiszChceZobaczycDoXLS.style.color = "";
KtoraStronaDoPobrania--;
window[TablicaPrzyciskow[NumerDiva][NumerPrzycisku].selektor].style.color = "green";
}
}
function PobierzNieInteresuje()
{
KtoraStronaDoPobrania++;
console.log("Która strona do pobrania: "+KtoraStronaDoPobrania, "z "+IleStronZOcenami);
if (KtoraStronaDoPobrania <= IleStronZOcenami)
{
var Request = new XMLHttpRequest();
Request.onerror = function()
{
window[TablicaPrzyciskow[NumerDiva][NumerPrzycisku].selektor].textContent = "błąd pobierania";
window[TablicaPrzyciskow[NumerDiva][NumerPrzycisku].selektor].style.color = "red";
};
Request.onload = PrzetworzNieInteresuje;
Request.open("GET", "//www.filmweb.pl/user/"+NazwaProfilu.split(" ").join("+")+"/"+TablicaPrzyciskow[NumerDiva][NumerPrzycisku].parametr+KtoraStronaDoPobrania, true);
Request.send();
}
else
{
EksportOcen_PrzyciskZapiszNieInteresujeDoXLS.removeEventListener("click", Ostrzezenie, false);
EksportOcen_PrzyciskZapiszNieInteresujeDoXLS.addEventListener("click", ZapiszNieInteresujeDoXLS, false);
EksportOcen_PrzyciskZapiszNieInteresujeDoXLS.setAttribute("download", NazwaProfilu+TablicaPrzyciskow[NumerDiva][NumerPrzycisku].plik);
EksportOcen_PrzyciskZapiszNieInteresujeDoXLS.style.color = "";
KtoraStronaDoPobrania--;
window[TablicaPrzyciskow[NumerDiva][NumerPrzycisku].selektor].style.color = "green";
}
}
function PrzetworzOceny()
{
TempArray = [];
TempObject = {};
var TempNode2;
var Response = document.implementation.createHTMLDocument("");
Response.documentElement.innerHTML = this.responseText;
if (KtoraStronaDoPobrania === 1)
{
if ( ! Response.querySelector("span.blockHeader__titleInfoCount"))
{
window[TablicaPrzyciskow[NumerDiva][NumerPrzycisku].selektor].textContent = "brak ocen";
window[TablicaPrzyciskow[NumerDiva][NumerPrzycisku].selektor].style.color = "red";
return;
}
IloscOcen = Response.querySelector("span.blockHeader__titleInfoCount").textContent;
IleStronZOcenami = Response.querySelector("section[data-pages-count]").getAttribute("data-pages-count");
}
TempNode = Response.querySelector("div.userVotesPage__results span.dataSource");
var ListaID = [];
for (var i = 0; i < TempNode.children.length; i++)
{
ListaID.push(TempNode.children[i].id);
}
console.log("ListaID", ListaID);
var DivyZFilmami = Response.querySelectorAll("div.voteBoxes__box");
for (var i = 0, ID = ""; i < DivyZFilmami.length; i++, IloscPobranychOcen++)
{
RowSelector = Tabela.insertRow();
//ID
CellSelector = RowSelector.insertCell();
ID = DivyZFilmami[i].getAttribute("data-id");
CellSelector.textContent = ID;
//Tytuł polski
CellSelector = RowSelector.insertCell();
TempNode2 = DivyZFilmami[i].querySelector("a.preview__link");
if (TempNode2 !== null)
{
TempNode = document.createElement("a");
TempNode.href = "https://www.filmweb.pl"+DivyZFilmami[i].querySelector("a.preview__link").getAttribute("href");
TempNode.textContent = TempNode2.textContent;
CellSelector.appendChild(TempNode);
}
//Tytuł oryginalny
CellSelector = RowSelector.insertCell();
TempNode2 = DivyZFilmami[i].querySelector("div.preview__alternateTitle");
if (TempNode2 !== null) {
TempNode = document.createElement("a");
TempNode.href = "https://www.filmweb.pl"+DivyZFilmami[i].querySelector("a.preview__link").getAttribute("href");
TempNode.textContent = TempNode2.textContent;
CellSelector.appendChild(TempNode);
}
else
{
CellSelector.appendChild(CellSelector.previousSibling.firstChild.cloneNode(true));
}
//Rok produkcji
CellSelector = RowSelector.insertCell();
TempNode = DivyZFilmami[i].querySelector("div.preview__year");
if (TempNode !== null) {
CellSelector.textContent = TempNode.textContent;
}
var VoteInfo = "";
if (IDWyswietlanegoUsera == NaszeID)
{
var VoteURL = "https://www.filmweb.pl/api/v1/logged/vote/"+TablicaPrzyciskow[NumerDiva][NumerPrzycisku].tytul_fw+"/"+ID+"/details";
}
else
{
var VoteURL = "https://www.filmweb.pl/api/v1/logged/friend/"+NazwaProfilu+"/vote/"+TablicaPrzyciskow[NumerDiva][NumerPrzycisku].tytul_fw+"/"+ID+"/details";
}
var Request = new XMLHttpRequest();
Request.onerror = function()
{
window[TablicaPrzyciskow[NumerDiva][NumerPrzycisku].selektor].textContent = "błąd pobierania";
window[TablicaPrzyciskow[NumerDiva][NumerPrzycisku].selektor].style.color = "orange";
};
Request.onload = function()
{
VoteInfo = JSON.parse(this.response);
};
Request.open("GET", VoteURL, false);
Request.send();
//Ulubione
CellSelector = RowSelector.insertCell();
if (VoteInfo.favorite)
{
CellSelector.textContent = "tak";
}
//Ocena
CellSelector = RowSelector.insertCell();
VoteInfo.rate === 0 ? CellSelector.textContent = "brak oceny" : CellSelector.textContent = VoteInfo.rate;
//Komentarz
CellSelector = RowSelector.insertCell();
if (VoteInfo.comment)
{
CellSelector.textContent = VoteInfo.comment;
}
//Gatunek
CellSelector = RowSelector.insertCell();
TempNode = DivyZFilmami[i].querySelector(".preview__detail--genres");
if (TempNode !== null)
{
for (var j = 0; j < TempNode.children.length; j++)
{
if (j > 0)
{
CellSelector.textContent += ", ";
}
CellSelector.textContent += TempNode.children[j].textContent;
}
}
//Data
CellSelector = RowSelector.insertCell();
if (VoteInfo.viewDate)
{
var date = VoteInfo.viewDate.toString().substring(0, 4);
if (VoteInfo.viewDate.toString().substring(4, 6) != "00")
{
date = VoteInfo.viewDate.toString().substring(4, 6)+"-"+date;
if (VoteInfo.viewDate.toString().substring(6, 8) != "00")
{
date = VoteInfo.viewDate.toString().substring(6, 8)+"-"+date;
}
}
CellSelector.textContent = date;
}
}
window[TablicaPrzyciskow[NumerDiva][NumerPrzycisku].selektor].textContent = "pobrano "+IloscPobranychOcen+"/"+IloscOcen+" ocen";
window[TablicaPrzyciskow[NumerDiva][NumerPrzycisku].selektor].style.color = "orange";
setTimeout(function()
{
PobierzOceny();
}, OpoznieniePobraniaStrony);
}
function PrzetworzChce()
{
TempArray = [];
TempObject = {};
var TempNode2;
var Response = document.implementation.createHTMLDocument("");
Response.documentElement.innerHTML = this.responseText;
if (KtoraStronaDoPobrania === 1)
{
if ( ! Response.querySelector("span.blockHeader__titleInfoCount") || ! Number(Response.querySelector("section[data-pages-count]").getAttribute("data-pages-count")))
{
window[TablicaPrzyciskow[NumerDiva][NumerPrzycisku].selektor].textContent = "brak wpisów";
window[TablicaPrzyciskow[NumerDiva][NumerPrzycisku].selektor].style.color = "red";
return;
}
IloscOcen = Response.querySelector("span.blockHeader__titleInfoCount").textContent;
IleStronZOcenami = Response.querySelector("section[data-pages-count]").getAttribute("data-pages-count");
}
var ListaFilmow = Response.querySelectorAll("div.userVotesPage__results > div.userVotesPage__result");
for (var i = 0, ID = ""; i < ListaFilmow.length; i++, IloscPobranychOcen++)
{
RowSelector = Tabela.insertRow();
//ID
CellSelector = RowSelector.insertCell();
ID = ListaFilmow[i].getAttribute("data-id");
CellSelector.textContent = ID;
//Tytuł polski
CellSelector = RowSelector.insertCell();
TempNode2 = ListaFilmow[i].querySelector("a.preview__link");
if (TempNode2 !== null)
{
TempNode = document.createElement("a");
TempNode.href = "https://www.filmweb.pl"+ListaFilmow[i].querySelector("a.preview__link").getAttribute("href");
TempNode.textContent = TempNode2.textContent;
CellSelector.appendChild(TempNode);
}
//Tytuł oryginalny
CellSelector = RowSelector.insertCell();
TempNode2 = ListaFilmow[i].querySelector("div.preview__alternateTitle");
if (TempNode2 !== null) {
TempNode = document.createElement("a");
TempNode.href = "https://www.filmweb.pl"+ListaFilmow[i].querySelector("a.preview__link").getAttribute("href");
TempNode.textContent = TempNode2.textContent;
CellSelector.appendChild(TempNode);
}
else
{
CellSelector.appendChild(CellSelector.previousSibling.firstChild.cloneNode(true));
}
//Rok produkcji
CellSelector = RowSelector.insertCell();
TempNode = ListaFilmow[i].querySelector("div.preview__year");
if (TempNode !== null) {
CellSelector.textContent = TempNode.textContent;
}
//Jak bardzo chce
CellSelector = RowSelector.insertCell();
TempNode = ListaFilmow[i].querySelector("div.wantToSeeRateBox__message");
if (TempNode !== null) {
CellSelector.textContent = TempNode.textContent;
}
//Gatunek
CellSelector = RowSelector.insertCell();
TempNode = ListaFilmow[i].querySelector(".preview__detail--genres");
if (TempNode !== null)
{
for (var j = 0; j < TempNode.children.length; j++)
{
if (j > 0)
{
CellSelector.textContent += ", ";
}
CellSelector.textContent += TempNode.children[j].textContent;
}
}
}
window[TablicaPrzyciskow[NumerDiva][NumerPrzycisku].selektor].textContent = "pobrano "+IloscPobranychOcen+"/"+IloscOcen+" wpisów";
window[TablicaPrzyciskow[NumerDiva][NumerPrzycisku].selektor].style.color = "orange";
setTimeout(function()
{
PobierzChce();
}, OpoznieniePobraniaStrony);
}
function PrzetworzNieInteresuje()
{
TempArray = [];
TempObject = {};
var TempNode2;
var Response = document.implementation.createHTMLDocument("");
Response.documentElement.innerHTML = this.responseText;
if (KtoraStronaDoPobrania === 1)
{
if ( ! Response.querySelector("span.blockHeader__titleInfoCount") || ! Number(Response.querySelector("section[data-pages-count]").getAttribute("data-pages-count")))
{
window[TablicaPrzyciskow[NumerDiva][NumerPrzycisku].selektor].textContent = "brak wpisów";
window[TablicaPrzyciskow[NumerDiva][NumerPrzycisku].selektor].style.color = "red";
return;
}
IloscOcen = Response.querySelector("span.blockHeader__titleInfoCount").textContent;
IleStronZOcenami = Response.querySelector("section[data-pages-count]").getAttribute("data-pages-count");
}
var ListaFilmow = Response.querySelectorAll("div.userVotesPage__results > div.userVotesPage__result");
for (var i = 0, ID = ""; i < ListaFilmow.length; i++, IloscPobranychOcen++)
{
RowSelector = Tabela.insertRow();
//ID
CellSelector = RowSelector.insertCell();
ID = ListaFilmow[i].getAttribute("data-id");
CellSelector.textContent = ID;
//Tytuł polski
CellSelector = RowSelector.insertCell();
TempNode2 = ListaFilmow[i].querySelector("a.preview__link");
if (TempNode2 !== null)
{
TempNode = document.createElement("a");
TempNode.href = "https://www.filmweb.pl"+ListaFilmow[i].querySelector("a.preview__link").getAttribute("href");
TempNode.textContent = TempNode2.textContent;
CellSelector.appendChild(TempNode);
}
//Tytuł oryginalny
CellSelector = RowSelector.insertCell();
TempNode2 = ListaFilmow[i].querySelector("div.preview__alternateTitle");
if (TempNode2 !== null) {
TempNode = document.createElement("a");
TempNode.href = "https://www.filmweb.pl"+ListaFilmow[i].querySelector("a.preview__link").getAttribute("href");
TempNode.textContent = TempNode2.textContent;
CellSelector.appendChild(TempNode);
}
else
{
CellSelector.appendChild(CellSelector.previousSibling.firstChild.cloneNode(true));
}
//Rok produkcji
CellSelector = RowSelector.insertCell();
TempNode = ListaFilmow[i].querySelector("div.preview__year");
if (TempNode !== null) {
CellSelector.textContent = TempNode.textContent;
}
//Gatunek
CellSelector = RowSelector.insertCell();
TempNode = ListaFilmow[i].querySelector(".preview__detail--genres");
if (TempNode !== null)
{
for (var j = 0; j < TempNode.children.length; j++)
{
if (j > 0)
{
CellSelector.textContent += ", ";
}
CellSelector.textContent += TempNode.children[j].textContent;
}
}
}
window[TablicaPrzyciskow[NumerDiva][NumerPrzycisku].selektor].textContent = "pobrano "+IloscPobranychOcen+"/"+IloscOcen+" wpisów";
window[TablicaPrzyciskow[NumerDiva][NumerPrzycisku].selektor].style.color = "orange";
setTimeout(function()
{
PobierzNieInteresuje();
}, OpoznieniePobraniaStrony);
}
function ZapiszOcenyDoXLS()
{
return ExcellentExport.excel(EksportOcen_PrzyciskZapiszOcenyDoXLS, "userscript", "Oceny");
}
function ZapiszChceZobaczycDoXLS()
{
return ExcellentExport.excel(EksportOcen_PrzyciskZapiszChceZobaczycDoXLS, "userscript", "Chcę zobaczyć");
}
function ZapiszNieInteresujeDoXLS()
{
return ExcellentExport.excel(EksportOcen_PrzyciskZapiszNieInteresujeDoXLS, "userscript", "Nie interesuje");
}
function StworzTabelke()
{
Tabela = document.querySelector("table#userscript");
if (Tabela !== null)
{
document.body.removeChild(Tabela);
}
Tabela = document.createElement("table");
Tabela.id = "userscript";
Tabela.style.display = "none";
document.body.appendChild(Tabela);
RowSelector = Tabela.insertRow();
KtoreElementy = TablicaPrzyciskow[NumerDiva][NumerPrzycisku].ktoreelementy.split(",");
for (var i = 0; i < KtoreElementy.length; i++)
{
ListaKolumn[KtoreElementy[i]].CzyDodac = true;
CellSelector = document.createElement("th");
CellSelector.id = "abc";
CellSelector.textContent = ListaKolumn[KtoreElementy[i]].NaglowekTabeli;
RowSelector.appendChild(CellSelector);
}
}
function Ostrzezenie()
{
alert("Najpierw pobierz którąś kategorię.");
}
}, 500);