Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function doNothing() {};
- function sleep(ms) {
- setTimeout(myFunction, ms);
- };
- function myFunction() {
- console.log('waiting complete');
- //alert("Hello");
- };
- function doSth() {
- console.log("jjj");
- document2 = document;
- document = document2;
- }
- function getElementByXpath(path) {
- return document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
- };
- function goNext() {
- button_next = getElementByXpath("//*[contains(@aria-label,'Wyświetl następne zdjęcie')]");
- button_next.click();
- };
- function getElementsByXpath(path) {
- var elements = [];
- var iterator = document.evaluate(path, document, null, XPathResult.UNORDERED_NODE_ITERATOR_TYPE, null );
- try {
- var thisNode = iterator.iterateNext();
- //elements.push(thisNode);
- while (thisNode) {
- elements.push(thisNode);
- //alert( thisNode.textContent );
- thisNode = iterator.iterateNext();
- }
- }
- catch (e) {
- console.log( 'Błąd: drzewo dokumentu zostało zmodyfikowane podczas iteracji ' + e );
- }
- return elements;
- };
- function getNonZeroSizeElement(collection) {
- var node;
- for (element in collection) {
- width = collection[element].offsetWidth;
- if (width > 0) {
- node = collection[element];
- break;
- } else {
- //
- }
- }
- return node;
- };
- function editTime() {
- collection_data = getElementsByXpath("//*[contains(@aria-label,'Data')]");
- element_data = getNonZeroSizeElement(collection_data);
- element_data.click();
- };
- function getMin() {
- input_godzina = getElementByXpath("(//input[contains(@aria-label,'Godzina')])");
- console.log(input_godzina.value);
- };
- function setNewTime(h, m) {
- input_godzina = getElementByXpath("(//input[contains(@aria-label,'Godzina')])");
- //while(!input_godzina) {
- // console.log("trying to find godzina element");
- // input_godzina = getElementByXpath("(//input[contains(@aria-label,'Godzina')])");
- //}
- console.log(input_godzina.value);
- input_godzina.value = h;
- input_minuta = getElementByXpath("(//input[contains(@aria-label,'Minuty')])");
- //while(!input_minuta) {
- // console.log("trying to find minuta element");
- // input_minuta = getElementByXpath("(//input[contains(@aria-label,'Minuty')])");
- //}
- console.log(input_minuta.value);
- input_minuta.value = m;
- input_minuta.value = m;
- collection_zapisz_node = getElementsByXpath('//text()[.="Zapisz"]/../../..');
- element_zapisz_node = getNonZeroSizeElement(collection_zapisz_node);
- button_zapisz = element_zapisz_node;
- console.log(input_godzina.value);
- console.log(input_minuta.value);
- //sleep (3000);
- button_zapisz.click();
- sleep (4000);
- };
- function dupa() {
- //collection_data = getElementsByXpath("//*[contains(@aria-label,'Data')]");
- //element_data = getNonZeroSizeElement(collection_data);
- collection_model_aparatu = getElementsByXpath("//*[contains(@aria-label,'Model aparatu')]");
- element_model_aparatu = getNonZeroSizeElement(collection_model_aparatu);
- model_aparatu = element_model_aparatu.innerText;
- console.log("model aparatu" + model_aparatu)
- collection_nazwa_pliku = getElementsByXpath("//*[contains(@aria-label,'Nazwa pliku')]");
- element_nazwa_pliku = getNonZeroSizeElement(collection_nazwa_pliku);
- nazwa_pliku = element_nazwa_pliku.innerText;
- date = nazwa_pliku.split(/-|_|\./);
- rok = date[0];
- mies = date[1];
- dzien = date[2];
- godzn = date[3];
- min = date[4];
- sek = date[5];
- console.log("godzina:" + godzn + " minuta:" + min);
- editTime();
- sleep(40000);
- setNewTime(godzn, min)
- };
- function change_date() {
- collection_data = getElementsByXpath("//*[contains(@aria-label,'Data')]");
- element_data = getNonZeroSizeElement(collection_data);
- collection_model_aparatu = getElementsByXpath("//*[contains(@aria-label,'Model aparatu')]");
- element_model_aparatu = getNonZeroSizeElement(collection_model_aparatu);
- model_aparatu = element_model_aparatu.innerText;
- collection_nazwa_pliku = getElementsByXpath("//*[contains(@aria-label,'Nazwa pliku')]");
- element_nazwa_pliku = getNonZeroSizeElement(collection_nazwa_pliku);
- nazwa_pliku = element_nazwa_pliku.innerText;
- date = nazwa_pliku.split(/-|_|\./);
- rok = date[0];
- mies = date[1];
- dzien = date[2];
- godzn = date[3];
- min = date[4];
- sek = date[5];
- //button_next = getElementByXpath("//*[contains(@aria-label,'Wyświetl następne zdjęcie')]");
- if (model_aparatu == "DSC-RX100" || model_aparatu == "DMC-TZ35") {
- editTime();
- setNewTime(godzn, min);
- }
- else {
- goNext();
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement