Skip to content

Instantly share code, notes, and snippets.

@BYK
Created January 13, 2015 09:49
Show Gist options
  • Save BYK/fbba8b47d4972e0848fb to your computer and use it in GitHub Desktop.
Save BYK/fbba8b47d4972e0848fb to your computer and use it in GitHub Desktop.
Hurriyet.com.tr Galeri Duzlestirici
var fullContent = [];
var contentContainer = document.querySelector('div.gBigOverlay');
contentContainer.innerHTML = '<img style="display: block; width: 16px; height: 16px; margin: 45% auto" src="' +
'data:image/gif;base64,R0lGODlhEAAQAPIAAP///wAAAMLCwkJCQgAAAGJiYoKCgpKSkiH+GkNyZWF0ZWQgd2l0aCBhamF4bG9hZC5pbmZvACH5BAAKAAAAIf8LTkVUU0NBUEUyLjADAQAAACwAAAAAEAAQAAADMwi63P4wyklrE2MIOggZnAdOmGYJRbExwroUmcG2LmDEwnHQLVsYOd2mBzkYDAdKa+dIAAAh+QQACgABACwAAAAAEAAQAAADNAi63P5OjCEgG4QMu7DmikRxQlFUYDEZIGBMRVsaqHwctXXf7WEYB4Ag1xjihkMZsiUkKhIAIfkEAAoAAgAsAAAAABAAEAAAAzYIujIjK8pByJDMlFYvBoVjHA70GU7xSUJhmKtwHPAKzLO9HMaoKwJZ7Rf8AYPDDzKpZBqfvwQAIfkEAAoAAwAsAAAAABAAEAAAAzMIumIlK8oyhpHsnFZfhYumCYUhDAQxRIdhHBGqRoKw0R8DYlJd8z0fMDgsGo/IpHI5TAAAIfkEAAoABAAsAAAAABAAEAAAAzIIunInK0rnZBTwGPNMgQwmdsNgXGJUlIWEuR5oWUIpz8pAEAMe6TwfwyYsGo/IpFKSAAAh+QQACgAFACwAAAAAEAAQAAADMwi6IMKQORfjdOe82p4wGccc4CEuQradylesojEMBgsUc2G7sDX3lQGBMLAJibufbSlKAAAh+QQACgAGACwAAAAAEAAQAAADMgi63P7wCRHZnFVdmgHu2nFwlWCI3WGc3TSWhUFGxTAUkGCbtgENBMJAEJsxgMLWzpEAACH5BAAKAAcALAAAAAAQABAAAAMyCLrc/jDKSatlQtScKdceCAjDII7HcQ4EMTCpyrCuUBjCYRgHVtqlAiB1YhiCnlsRkAAAOwAAAAAAAAAAAA==' +
'">';
contentContainer.style.display = 'block';
var extractor = function (doc) {
if (!doc) doc = document;
var nextPageLinkContainer = doc.querySelector('li.gra');
var nextPageLink = nextPageLinkContainer && nextPageLinkContainer.querySelector('a');
var nextPageURL = nextPageLink && nextPageLink.href;
var contentNode = doc.querySelector('div.galDesc');
var content = contentNode && contentNode.textContent.trim();
if (content) fullContent.push(content);
if (nextPageURL) {
var xhr = new XMLHttpRequest();
xhr.onload = function () { extractor(xhr.response); }
xhr.open('GET', nextPageURL, true);
xhr.responseType = 'document';
xhr.send();
} else {
var contentElement = fullContent.map(function (text) {
var tNode = document.createTextNode(text);
var p = document.createElement('p');
p.style.margin = '12px 0';
p.appendChild(tNode);
return p;
}).reduce(function (cont, node) {
cont.appendChild(node);
return cont;
}, document.createElement('div'));
contentElement.style.color = '#fff';
contentElement.style.fontSize = '24px';
contentElement.style.width = '75%';
contentElement.style.height = '90%';
contentElement.style.margin = '5% auto';
contentElement.style.overflow = 'auto';
contentContainer.innerHTML = '';
contentContainer.appendChild(contentElement);
contentContainer.style.display = 'block';
}
};
extractor();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment