Advertisement
Guest User

Untitled

a guest
Oct 19th, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function doNothing() {};
  2.  
  3. function sleep(ms) {
  4.  
  5.     setTimeout(myFunction, ms);
  6.  
  7. };
  8.  
  9.  
  10. function myFunction() {
  11.     console.log('waiting complete');
  12.     //alert("Hello");
  13. };
  14.  
  15.  
  16.  
  17. function doSth() {
  18.  
  19.  
  20.     console.log("jjj");
  21.     document2 = document;
  22.     document = document2;
  23.    
  24.    
  25. }
  26.  
  27.  
  28.  
  29. function getElementByXpath(path) {
  30.   return document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  31. };
  32.  
  33.  
  34. function goNext() {
  35.    
  36.     button_next = getElementByXpath("//*[contains(@aria-label,'Wyświetl następne zdjęcie')]");
  37.    
  38.    
  39.     button_next.click();
  40. };
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47. function getElementsByXpath(path) {
  48.         var elements = [];
  49.         var iterator = document.evaluate(path, document, null, XPathResult.UNORDERED_NODE_ITERATOR_TYPE, null );
  50.  
  51.         try {
  52.           var thisNode = iterator.iterateNext();
  53.           //elements.push(thisNode);
  54.          
  55.          
  56.          
  57.           while (thisNode) {
  58.             elements.push(thisNode);
  59.             //alert( thisNode.textContent );
  60.             thisNode = iterator.iterateNext();
  61.            
  62.           }
  63.         }
  64.         catch (e) {
  65.           console.log( 'Błąd: drzewo dokumentu zostało zmodyfikowane podczas iteracji ' + e );
  66.         }
  67.  
  68. return elements;
  69. };
  70.  
  71. function getNonZeroSizeElement(collection) {
  72.    
  73.     var node;
  74.     for (element in collection) {
  75.  
  76.         width = collection[element].offsetWidth;
  77.        
  78.         if (width > 0) {
  79.                 node = collection[element];
  80.                 break;
  81.         } else {
  82.                 //
  83.         }
  84.        
  85.     }
  86.     return node;
  87. };
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94. function editTime() {
  95.  
  96.         collection_data = getElementsByXpath("//*[contains(@aria-label,'Data')]");
  97.         element_data = getNonZeroSizeElement(collection_data);
  98.         element_data.click();
  99. };
  100.  
  101.  
  102.  
  103. function getMin() {
  104.  
  105.         input_godzina = getElementByXpath("(//input[contains(@aria-label,'Godzina')])");
  106.         console.log(input_godzina.value);
  107.  
  108. };
  109.  
  110.  
  111. function setNewTime(h, m) {
  112.  
  113.         input_godzina = getElementByXpath("(//input[contains(@aria-label,'Godzina')])");
  114.         //while(!input_godzina) {
  115.         //  console.log("trying to find godzina element");
  116.         //  input_godzina = getElementByXpath("(//input[contains(@aria-label,'Godzina')])");
  117.         //}
  118.        
  119.         console.log(input_godzina.value);
  120.         input_godzina.value = h;
  121.         input_minuta = getElementByXpath("(//input[contains(@aria-label,'Minuty')])");
  122.         //while(!input_minuta) {
  123.         //  console.log("trying to find minuta element");
  124.         //  input_minuta = getElementByXpath("(//input[contains(@aria-label,'Minuty')])");
  125.         //}
  126.        
  127.         console.log(input_minuta.value);
  128.         input_minuta.value = m;
  129.         input_minuta.value = m;
  130.         collection_zapisz_node = getElementsByXpath('//text()[.="Zapisz"]/../../..');
  131.         element_zapisz_node = getNonZeroSizeElement(collection_zapisz_node);
  132.         button_zapisz = element_zapisz_node;
  133.         console.log(input_godzina.value);
  134.         console.log(input_minuta.value);
  135.         //sleep (3000);
  136.         button_zapisz.click();
  137.         sleep (4000);
  138.        
  139.  
  140. };
  141.  
  142.  
  143. function dupa() {
  144.  
  145.     //collection_data = getElementsByXpath("//*[contains(@aria-label,'Data')]");
  146.     //element_data = getNonZeroSizeElement(collection_data);
  147.  
  148.  
  149.     collection_model_aparatu = getElementsByXpath("//*[contains(@aria-label,'Model aparatu')]");
  150.     element_model_aparatu = getNonZeroSizeElement(collection_model_aparatu);
  151.     model_aparatu = element_model_aparatu.innerText;
  152.    
  153.     console.log("model aparatu" + model_aparatu)
  154.  
  155.     collection_nazwa_pliku = getElementsByXpath("//*[contains(@aria-label,'Nazwa pliku')]");
  156.     element_nazwa_pliku = getNonZeroSizeElement(collection_nazwa_pliku);
  157.     nazwa_pliku = element_nazwa_pliku.innerText;
  158.     date = nazwa_pliku.split(/-|_|\./);
  159.     rok = date[0];
  160.     mies = date[1];
  161.     dzien = date[2];
  162.     godzn = date[3];
  163.     min = date[4];
  164.     sek = date[5];
  165.    
  166.     console.log("godzina:" + godzn + " minuta:" + min);
  167.    
  168.        
  169.         editTime();
  170.         sleep(40000);
  171.         setNewTime(godzn, min)
  172.        
  173.  
  174. };
  175.  
  176.  
  177. function change_date() {
  178.  
  179.  
  180.     collection_data = getElementsByXpath("//*[contains(@aria-label,'Data')]");
  181.     element_data = getNonZeroSizeElement(collection_data);
  182.  
  183.  
  184.     collection_model_aparatu = getElementsByXpath("//*[contains(@aria-label,'Model aparatu')]");
  185.     element_model_aparatu = getNonZeroSizeElement(collection_model_aparatu);
  186.     model_aparatu = element_model_aparatu.innerText;
  187.  
  188.     collection_nazwa_pliku = getElementsByXpath("//*[contains(@aria-label,'Nazwa pliku')]");
  189.     element_nazwa_pliku = getNonZeroSizeElement(collection_nazwa_pliku);
  190.     nazwa_pliku = element_nazwa_pliku.innerText;
  191.     date = nazwa_pliku.split(/-|_|\./);
  192.     rok = date[0];
  193.     mies = date[1];
  194.     dzien = date[2];
  195.     godzn = date[3];
  196.     min = date[4];
  197.     sek = date[5];
  198.  
  199.     //button_next = getElementByXpath("//*[contains(@aria-label,'Wyświetl następne zdjęcie')]");
  200.  
  201.  
  202.  
  203.             if (model_aparatu == "DSC-RX100" || model_aparatu == "DMC-TZ35") {
  204.            
  205.             editTime();
  206.             setNewTime(godzn, min);
  207.  
  208.             }
  209.  
  210.             else {
  211.  
  212.                 goNext();
  213.  
  214.             }
  215.  
  216. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement