SlootLite

Untitled

Mar 30th, 2017
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. getElement('http://www.tomskneft.ru/about/', '.editable-content', function(element) {
  2.     console.log(element.innerHTML);
  3. });
  4.  
  5. function getElement(url, selector, c) {
  6.     request(new XMLHttpRequest());
  7.  
  8.     function request(xhr) {
  9.         xhr.open('GET', 'https://crossorigin.me/' + url, true);
  10.         xhr.send();
  11.         xhr.onreadystatechange = function() {
  12.             if(xhr.readyState == 4) {
  13.                 if(xhr.status == 200) {
  14.                     html = document.createElement('div');
  15.                     html.innerHTML = xhr.responseText;
  16.                     c(html.querySelector(selector));
  17.                 }
  18.             }
  19.         }
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment