fork download
  1. // ==UserScript==
  2. // @include /http://market\.yandex\.ru/model-spec\.xml\?modelid=\d+&hid=\d+/
  3. // @grant none
  4. // ==/UserScript==
  5.  
  6. var tel = document.querySelector('.l-page__left');
  7.  
  8. var div = document.createElement('div');
  9. div.className = 'tovtable';
  10.  
  11. var table = tel.querySelector('.b-properties');
  12. table.removeAttribute('xmlns:lego');
  13. table.removeAttribute('class');
  14. var p = tel.querySelector('.b-modelspec__note');
  15. p.removeAttribute('xmlns:lego');
  16. p.removeAttribute('class');
  17.  
  18. table.parentNode.insertBefore(div, table);
  19.  
  20. div.appendChild(table);
  21.  
  22. var xpath = "//div[contains(concat(' ', @class, ' '), ' b-properties__title ')]";
  23. var elements = document.evaluate(xpath, div, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null);
  24.  
  25. var actualTh = elements.iterateNext();
  26. var innerTh = actualTh.innerHTML;
  27. var parrentOfTh = actualTh.parentNode;
  28. var realTd = document.createElement('td');
  29. while (actualTh) {
  30. innerTh = actualTh.innerHTML;
  31. parrentOfTh = actualTh.parentNode;
  32. parrentOfTh.removeChild(actualTh);
  33. realTd = document.createElement('td');
  34. parrentOfTh.appendChild(realTd);
  35. actualTh = elements.iterateNext();
  36. }
  37.  
  38. var res = tel.innerHTML;
  39.  
  40. var a = document.createElement('a');
  41. a.href = 'data:text/html;charset=utf-8,' + res;
  42. a.download = 'file1.html';
  43. a.style.background = 'red';
  44. a.innerHTML = 'Нажми меня!';
  45.  
  46. var child = document.querySelector('.b-breadcrumbs');
  47. var parent = child.parentNode;
  48. parent.insertBefore(a, child);
  49.  
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
// ==UserScript==
// @include /http://market\.yandex\.ru/model-spec\.xml\?modelid=\d+&hid=\d+/
// @grant       none
// ==/UserScript==

var tel = document.querySelector('.l-page__left');

var div = document.createElement('div');
div.className = 'tovtable';

var table = tel.querySelector('.b-properties');
table.removeAttribute('xmlns:lego');
table.removeAttribute('class');
var p = tel.querySelector('.b-modelspec__note');
p.removeAttribute('xmlns:lego');
p.removeAttribute('class');

table.parentNode.insertBefore(div, table);

div.appendChild(table);

var xpath = "//div[contains(concat(' ', @class, ' '), ' b-properties__title ')]";
var elements = document.evaluate(xpath, div, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null);

var actualTh = elements.iterateNext();
var innerTh = actualTh.innerHTML;
var parrentOfTh = actualTh.parentNode;
var realTd = document.createElement('td');
while (actualTh) {
  innerTh = actualTh.innerHTML;
  parrentOfTh = actualTh.parentNode;
  parrentOfTh.removeChild(actualTh);
  realTd = document.createElement('td');
  parrentOfTh.appendChild(realTd);
  actualTh = elements.iterateNext();
}

var res = tel.innerHTML;

var a = document.createElement('a');
a.href = 'data:text/html;charset=utf-8,' + res;
a.download = 'file1.html';
a.style.background = 'red';
a.innerHTML = 'Нажми меня!';

var child = document.querySelector('.b-breadcrumbs');
var parent = child.parentNode;
parent.insertBefore(a, child);