Skip to content

Character as graphics to GM.notificationΒ #2609

@sjehuda

Description

@sjehuda

Greetings.

I advise to add function characterAsSvgDataUri.

function characterAsSvgDataUri(character) {
  // An SVG string with a character.
  const svgString = `
    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
        <text y=".9em" font-size="90">${character}</text>
    </svg>
  `;
  // Encode the SVG string to base64.
  const base64Svg = btoa(unescape(encodeURIComponent(svgString)));
  // Return a data URL.
  return `data:image/svg+xml;base64,${base64Svg}`;
}

While this directive would set an image based on a given URI.

GM.notification(message, "πŸ“° Greasemonkey Newspaper", URI);

This directive would set an image based on a given character.

GM.notification(message, "πŸ“° Greasemonkey Newspaper", "🐡");

Currently, I utilize this directive.

GM.notification(message, "πŸ“° Greasemonkey Newspaper", characterAsSvgDataUri(graphics));

Reference.

https://greasyfork.org/en/scripts/465932-newspaper-syndication-feed-reader/diff?v1=1705239&v2=1705216

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions