Created
April 29, 2015 10:00
-
-
Save pulges/b420ac0ca096b81b1d56 to your computer and use it in GitHub Desktop.
Fix Voog images and urls for email templating (Works in Chrome only)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var saveData = function (blob, fileName) { | |
var a = document.createElement("a"); | |
document.body.appendChild(a); | |
var url = window.URL.createObjectURL(blob); | |
a.href = url; | |
a.download = fileName; | |
a.click(); | |
window.URL.revokeObjectURL(url); | |
}; | |
var containers = document.querySelectorAll('.image-container'); | |
var img, cstyle; | |
for (var i = containers.length; i--;) { | |
img = containers[i].querySelector('img'); | |
if (img) { | |
cstyle = window.getComputedStyle(containers[i]); | |
img.removeAttribute('style'); | |
img.style.width = cstyle.width; | |
img.style.height = cstyle.height; | |
img.style.cssFloat = cstyle.cssFloat; | |
containers[i].parentNode.insertBefore(img, containers[i]); | |
} | |
containers[i].parentNode.removeChild(containers[i]); | |
} | |
var imgs = document.querySelectorAll('img'); | |
for (var j = imgs.length; j--;) { | |
imgs[j].setAttribute('src', imgs[j].src.replace(/^\/photos\//, document.location.protocol + '//' + document.location.host + '/photos/')); | |
} | |
var links = document.querySelectorAll('a'); | |
for (var l = links.length; l--;) { | |
links[l].setAttribute('href', links[l].href.replace(/^\//, document.location.protocol + '//' + document.location.host + '/')); | |
} | |
var pfill = document.querySelector('script[src*="static.voog.com"]'); | |
if (pfill) { | |
pfill.parentNode.removeChild(pfill); | |
} | |
var code = document.querySelector('html').outerHTML; | |
var data = new Blob([code], {type: 'application/octet-stream'}); | |
saveData(data, "uudiskiri.html"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment