Danbooru

[Userscript] Translate Pixiv Tags

Posted under General

BrokenEagle98 said:

Found an interesting error recently. artist #168452 was created which begins with a "<" and ends with a ">", so when it gets rendered in page the HTML thinks it's an HTML tag so it doesn't show up on the screen. I'm not sure such tag names should even be allowed, but for now at least it seems like they can be created.

But "<" and ">" are ASCII characters like !@#$%^&*()_+-='";:/\[]{}|`~.

coredumperror said:

Pixiv updated their UI (quite radically, this time), and this script broke again. It still works fine on the Add Bookmark page, but it doesn't work at all on the main page for the artwork.

I tried to look into how things had changed, to hopefully figure out a fix. But it looks like Pixiv now uses these mangled CSS classes that I can't figure out at all. :(

Now I also see new UI of the /member_illust.php
Queries "aside > section > div > div > a" and "figcaption footer a" works nice though they doesn't contains any id ┐( ̄ヘ ̄;)┌
Also, before you run the queries, you must wait until the content is added.

BrokenEagle98 said:

They are considered special characters in HTML since they are used to form the HTML tags. If you actually look at the HTML code, you'll find that all instances of "<" and ">" are made with the HTML entities &lt; and &gt;. (Reference: https://www.w3schools.com/html/html_entities.asp)

I mean that the tag name consists of printable ASCII characters except "*," anywhere, "~_-" at the begin, and "_" at the end (correct me if I missed some characters). And "<>" pass this rule hence they can be used in the tag name.

On pixiv, the script often doesn't translate tags, but always translate after page reloading.

And tooltip falls with error "Uncaught (in promise) TypeError: artist.other_names.split is not a function" on line 639 because artist.other_names already is array.

7nik said:

On pixiv, the script often doesn't translate tags, but always translate after page reloading.

This is a known issue that I haven't been able to resolve. Pixiv dynamically renders their pages in Javascript, which makes it hard for userscripts to hook into things. The script uses mutation observers to detect when the page changes, but apparently it doesn't always pick up changes when it should.

Release 2019.01.14

  • Artstation: Add Artstation support (credit to 7nik for implementing this).
  • Pixiv: Fix artist tags not appearing on profile pages.
  • Pixiv: Fix artist tags not appearing on profile pages when artist has no followers.
  • Misc: Fix artist tags returning matches for deleted artists.

Release 2019.07.04

Fixes

  • Added ignoring of false-positive results that Danbooru returns for some unsupported domains (bug #18)
  • Sometimes the popup with artist info was empty
  • Artist tag could be added multiple times (bug #9)
  • Fixed running the script in iframes (bug #10)
  • Pixiv: sometimes tags were not translated (bug #15)
  • Twitter: fixed blocked thumbnails (credit to BrokenEagle)

Changes

  • Improved performance by adding caching and the "only" parameter in Danbooru API calls (credit to BrokenEagle)
  • Now tags are also "translated" by their main name
  • Added ability to choose Danbooru server, number of previews, and cache lifetime (credit to BrokenEagle)
  • Twitter: added translating of hastags (credit to BrokenEagle)
  • SauceNAO: added initial support
  • Pawoo: added initial support
  • CSS improvements

Release 2019.08.06

Fixes
  • In some cases the artist tooltip could be mostly outside the viewport.
  • The userscript couldn't automatically update if was installed via copy/paste (credit to BrokenEagle).
Changes
  • Now post preview also includes file size, resolution, source, rating, and time of upload.
  • NSFW previews are blurred, hover over them to unblur. This behavior can be adjusted in settings.
  • Limited size of main sections in the artist tooltip.
  • Main parts of the artist tooltip can be customized via pseudoelement ::part().
  • Added dark theme of the tooltip and adaptive background color.

Lucalo said:

Artist name tag and the popup with artist info don't show up with this script as of some weeks ago, even with the newest version 2019.07.26

If it still actual for the new release, could you provide more info: is it broken for all sites or only one; a few links were the script does not work.

Just wanted to chime in specifically about styling with the parts as mentioned by 7nik.

Parts

There are several part identifiers for the QTip popup in Translate Pixiv Tags:

  • container - The whole popup.
  • other-names - The other artist names located beneath the artist name.
  • url-list - The list of URLs beneath the header URLs.
  • post-list - The thumbnail section beneath the header Posts.
  • post-preview - The <img> element for each thumbnail.
  • rating-s - The <img> elements with a safe rating.
  • rating-q - The <img> elements with a questionable rating.
  • rating-e - The <img> elements with a explicit rating.
Usage

To specify a part, you use the CSS specifier for the outer container (.qtip-content) and then the part specifier.

.qtip-content::part(post-preview)

The above will address the images for each thumbnail.

Note: Only those elements with parts can be affected. Descendant elements cannot be affected.

Example

A scenario where one might want to use the above would be to hide all of the explicit images.

.qtip-content::part(rating-e) {
    display: none;
}

The above will hide all images with an explicit rating.

Release 2019.08.24

Fixes
  • #25: displayed incorrect image size
  • BCY: everything was broken.
  • DevianArt: uncolored tags.
  • SauceNAO: could translated deleted artists.
  • Simultaneous triggering of native and script tooltips.
  • Tag translating could use deleted wikis.
Changes
  • Added UI for settings.
  • Updated and cleaned CSS.
  • Updated some selectors for translating.
  • Pixiv: now native translations are removed only for translated tags.
  • Mobile Twitter: removed.
  • Improved choosing of background color in case of semi-transparent ones.

Release 2019.09.19

Fixes
  • #32: no obvious way to cancel settings changes.
  • #33: settings menu doesn't open for some artist tags.
  • DevianArt: fixed overridden color of the artist tag.
  • Fixed breakages caused by sites updating.
Changes
  • Added TweetDeck support.
  • Added pixivFanbox support.
  • Added alternative way to open settings: via Tampermonkey menu.
  • Added handling of network request limit (credit to BrokenEagle).
  • Internal improvements.
1 2 3