-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxkcd-transcript-get.js
More file actions
1 lines (1 loc) · 1.05 KB
/
xkcd-transcript-get.js
File metadata and controls
1 lines (1 loc) · 1.05 KB
1
javascript:(function(){var c=document.getElementById('comic');var t=document.getElementById('transcript');if(!c&&!t){alert('Divs not found');return;}var C=c?c.cloneNode(true):document.createElement('div');var T=t?t.cloneNode(true):document.createElement('div');T.style.display='block';var i=C.getElementsByTagName('img');for(var j=0;j<i.length;j++){i[j].src=i[j].src;}var H=`<!DOCTYPE html><html><head><meta charset="utf-8"><title>${document.title} (Extracted)</title><style>body{font-family:sans-serif;padding:20px;max-width:800px;margin:0 auto}#comic{margin-bottom:20px}#transcript{white-space:pre-wrap;background:#f5f5f5;padding:15px;border-radius:5px}</style></head><body><h1>${document.title}</h1>${C.outerHTML}<hr><h3>Transcript</h3>${T.outerHTML}</body></html>`;var%20b=new%20Blob([H],{type:'text/html'});var%20u=URL.createObjectURL(b);var%20a=document.createElement('a');a.href=u;a.download=(document.title.replace(/[^a-z0-9]/gi,'_').toLowerCase()||'xkcd')%20+%20'.html';document.body.appendChild(a);a.click();document.body.removeChild(a);URL.revokeObjectURL(u);})();