// ==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);
Standard input is empty
// ==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);