Last active
January 19, 2018 22:12
-
-
Save corysimmons/d4687ae37c86552c16aba66b8d0e2c47 to your computer and use it in GitHub Desktop.
Download inline <svg>s
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
javascript:void function()%7B"use strict"%3Bvar e%3D!0,t%3D!1,r%3Dvoid 0%3Btry%7Bfor(var o,a%3Ddocument.querySelectorAll("svg")%5BSymbol.iterator%5D()%3B!(e%3D(o%3Da.next()).done)%3Be%3D!0)%7Bvar i%3Do.value%3Bi.insertAdjacentHTML("beforebegin",%27<a href-lang%3D"image/svg%2Bxml" href%3D"data:image/svg%2Bxml%3Butf8,%27%2Bescape(i.outerHTML)%2B%27" style%3D"position: relative%3B z-index: 999%3B top: -15px%3B right: -15px%3B font-size: 10px%3B background: tomato%3B color: white%3B padding: 5px%3B">Download SVG</a>%27)%7D%7Dcatch(n)%7Bt%3D!0,r%3Dn%7Dfinally%7Btry%7B!e%26%26a%5B"return"%5D%26%26a%5B"return"%5D()%7Dfinally%7Bif(t)throw r%7D%7D%7D()%3B |
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
for (const svg of document.querySelectorAll('svg')) { | |
svg.insertAdjacentHTML('beforebegin', `<a href-lang="image/svg+xml" href="data:image/svg+xml;utf8,${escape(svg.outerHTML)}" style="position: relative; z-index: 999; top: -15px; right: -15px; font-size: 10px; background: tomato; color: white; padding: 5px;">Download SVG</a>`) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment