SVG Gobbler

Avatar of Chris Coyier
Chris Coyier

DigitalOcean 为您旅程的每个阶段提供云产品。 立即开始使用 200 美元的免费积分!

很棒的小项目 来自 Ross Moody

SVG Gobbler 是一个浏览器扩展,它可以在您正在查看的页面上找到矢量内容,并提供下载、优化、复制、查看代码或将其导出为图像的选项。

当网站使用 SVG 作为 <img> 时,您可以像其他任何图像一样右键单击/另存为。 但当 SVG 作为 <svg> 内联时(出于样式原因,这通常是有意义的),很难获得它的副本。 我通常会打开 DevTools,找到 <svg>,右键单击它,使用**复制 > 复制外部 HTML**,粘贴到文本文件中,并保存为 whatever.svg。 这比我想要的要多一点。

Show an open DevTools window with a contextual MacOS menu open on top of it with the option Copy highlighted, which opens to a second panel in the contextual menu where an option to copy the HTML is highlighted in bright blue.

使用 SVG Gobbler,我点击浏览器扩展,它会向我展示一个不错的选项网格

A browser window open with a black header that has the red SVG Gobbler logo flashed left and white buttons to send feedback and toggle dark mode flashed right. Below that is a grid of SVG icons, including the CSS-Tricks logo, a magnifying glass, a close icon, a downward chevron, the Jetpack logo, and an orange downward arrow.

我可以从这里快速下载它们,但请注意,如果我愿意,它甚至可以为我优化它们,或者导出为 PNG。 很棒! 我今天已经使用了它,而我今天才安装了它。

通过反馈,我想说最好

  1. 有一种方法可以调整 PNG 导出的尺寸(也可能允许我根据需要将其制作得很大)。
  2. 导出为下一代格式,它们甚至可能比 PNG 更好,例如 WebP 或 AVIF。
  3. 填充为 white 的 SVG 应该显示在非白色背景上,这样你就可以看到它们是什么。
  4. 可以选择让我在下载时命名文件,而不是总是将其命名为 gobbler-original.svg

一个远期目标是,以某种方式将网站上使用的 CSS 提取到 <svg> 中。 我注意到它发现的一些 SVG 在导出时看起来非常不同,因为页面正在使用 SVG 外部的样式来对其进行样式设置,而这些样式在导出时会丢失。

我想知道 Safari 扩展的更改是否可以让 Ross 轻松地将其移植到 Safari(甚至 Mobile Safari?!)。