Posts

For more information, see the search syntax documentation. Search results are sorted by creation date.

Search Results

Site and Policy » [Userscript] Bulk Tag Editor » Post 32

Site and Policy » [Userscript] Bulk Tag Editor » Post 31

Background Pony #BFC6
I have some proposed revisions:
  const booruDefault = {
...
    forbiddenRedirPath: '/', //new
    hasTagError: (str) => { //is this the best way to do this?  I dunno, I'm barely a hobbyist
      const dom = new DOMParser().parseFromString(str, 'text/html');
      return {
        errored: [...dom.getElementsByClassName('alert-danger')]
                 .some((ele) => ele.textContent.includes('Oops, something went wrong!')),
        messages: [...dom.getElementsByClassName('help-block')]
                  .map((ele) => ele.textContent),
      }; },
  async function throttle(fn, ...args) {
...
    try { //because we're throwing errors around
      const result = await new Promise(resolve => {
        window.setTimeout(() => {
          resolve(fn(...args));
        }, timeRemain);
      });
      GM_setValue(key, Date.now());
      return result;
    } finally {
      GM_setValue(key, Date.now()); //still need to do this while throwing errors around
    }
  async function bulkApplyTags(tagsToAdd, tagsToRemove) {
...
        await throttle(submitEdit, id, oldTags, newTags);
      } catch (err) {
        errors += 1;
// Also do stuff like styling thumbnails based on what the specific error is
      } finally {
  async function submitEdit(id, oldTags, newTags) {
...
    const abort = new AbortController(); //new
    const resp = await fetch(path, {
      method: 'POST',
      body: form,
      signal: abort.signal, //new
    });
    if (resp.status !== 200) {
      throw new Error('status code: ' + resp.status);
    } else if (resp.redirected) { //all new
      abort.abort();
      if ((window.location.origin + getBooruParam('forbiddenRedirPath')) == (resp.url))
        throw new Error('forbidden');
      else
        throw new Error('redirected');
    }
    const body = await resp.text();
    const errors = getBooruParam('hasTagError')(body);
    if (errors.errored) throw new Error('prevented', { cause: errors.messages });
The abort is because there’s no reason to load Derpibooru’s index page if tagging fails, saving 30-some KB, which is nothing in this day and age but it’s the principle of it…

1. If the tag change is rejected, count it as an error:
  • Although it could be thought of as “successfully failing” ie. working as intended vs. an error, not applying a change is an event a user* might want to follow up on.
    *me
    • Future features: highlight the images that the errors occurred on, with styles uniquely communicating which kind of failure occurred for them.
  • If the tag change is prevented due to permissions (such as tags being locked), philomena currently responds with a 302 redirect to ‘/’. fetch will resolve it as a status 200 with .redirect = true and .url as location.origin + '/'
    • I don’t see a way to know that a post’s tags are locked via the API or the data on the thumbnails page:
      • It can be found out in the aforementioned way, or
      • It could be found out by making yet another fetch, for the image’s page itself (not its API) and looking for <div class=\"js-imageform hidden\"><p>You can't edit the tags on this image. </p></div>.
  • If the tag change is prevented due to ratelimit violation, philomena responds with a 302 redirect to the referer
    • I couldn’t figure out a way to get the string that will be sent as the referrer without making a lot of janky assumptions; window.location.origin + window.location.pathname + window.location.search seems to be the default…but perhaps some other user extension would alter that, and I couldn’t find a way to get the actual referer string that will be sent by fetch’s Request - it just returns about:client verbatim.
    • So, instead, test for resp.redirected and hope that no other philomena implementation uses redirects for successful API responses.
  • Throw unique errors in these cases. As mentioned above, it might be nice to present which images encountered tagging errors, and what sort of tagging error (as you might just try again if it’s a network or ratelimit violation, vs. pursuing mod assistance with tag locked images.)
2. If the tag change is invalid, eg. trying to assign both safe and suggestive, philomena rejects the entire attempt and that should also be detected as an error.
  • When trying to apply invalid tags combos from the normal web form, the response contains a bunch of HTML (to replace certain elements on the page) and includes text like Oops, something went wrong! Please check the errors below. which could be detected. However, for reasons I can’t figure out, when making the requests through the userscript, even if I set all the headers and payload to be exactly the same, I find response body is empty/absent. Looks like a quirk(?) of the Chrome network tab - if I await and access resp.text() in the script, suddenly the response shows up.
    • Any idea why that is? Currently, I don’t have an idea how to detect that type of failure.
    • Instead, the tag validation could be re-created to proactively perform on the client-side in lieu of looking for it in responses.

Site and Policy » [Userscript] Bulk Tag Editor » Post 30

Site and Policy » [Userscript] Bulk Tag Editor » Post 29

Site and Policy » [Userscript] Bulk Tag Editor » Post 28

Background Pony #8E64
@Marker
Could you put this derpi thread here in the description or so in the script itself?
To ease finding it again in the future

Site and Policy » [Userscript] Bulk Tag Editor » Post 27

Site and Policy » [Userscript] Bulk Tag Editor » Post 26

🐴
Magnificent Metadata Maniac - #1 Assistant
Solar Guardian - Refused to surrender in the face of the Lunar rebellion and showed utmost loyalty to the Solar Empire (April Fools 2023).
Non-Fungible Trixie -
Magical Inkwell - Wrote MLP fanfiction consisting of at least around 1.5k words, and has a verified link to the platform of their choice

IRL 🎠 stallion
I can’t seem to get this to work with the FF Violentmonkey edition. The “tag edit” button is there, but it does nothing when I click it. Tried under both Mac and Debian.

Site and Policy » [Userscript] Bulk Tag Editor » Post 25

Site and Policy » [Userscript] Bulk Tag Editor » Post 24

Site and Policy » [Userscript] Bulk Tag Editor » Post 23

rautamiekka
Lunar Supporter - Helped forge New Lunar Republic's freedom in the face of the Solar Empire's oppressive tyrannical regime (April Fools 2023).
King Sombra - Celebrated the 10th anniversary of The Crystal Empire!
Elements of Harmony - Had an OC in the 2022 Community Collab
Magical Inkwell - Wrote MLP fanfiction consisting of at least around 1.5k words, and has a verified link to the platform of their choice
Speaking Fancy - Badge given to members that help with translations
Cool Crow - "Caw!" An awesome tagger
Magnificent Metadata Maniac - #1 Assistant
Preenhub - We all know what you were up to this evening~
Twinkling Balloon - Took part in the 2021 community collab.
My Little Pony - 1992 Edition

When trying to click the ‘Tag Editor’ button in a search, such as https://derpibooru.org/search?q=artist%3Amochii-maddness%2Csource_url%3Ahttps%3A%2F%2Fwww.deviantart.com%2Fmochii-maddness, simply nothing happens way or another, it’s like I never clicked the button.
  • Tampermonkey 4.14
  • Google Chrome 98.0.4758.102 (Official Build) (64-bit)
  • Primary install 1.1.2.
When checking the script in Tampermonkey’s editor, the editor has a problem with the line 16 // @inject-into page cuz it puts a yellow triangle next to the 1st slash in that line and says:
eslint: userscripts/no-invalid-headers - '@inject-into' is not a valid userscript header
Removing the line doesn’t change anything either.
I’ve tried rebooting Chrome, disabling Tampermonkey and the script separately from the button in the same line as the address box, rebooting Tampermonkey with the restart button in its settings, clicking the button to update the script, which found no updates, and refreshing that search page with both F5 and CTRL+F5, both before and after all of those.

Site and Policy » [Userscript] Bulk Tag Editor » Post 22

Site and Policy » [Userscript] Bulk Tag Editor » Post 21

Site and Policy » [Userscript] Bulk Tag Editor » Post 20

Site and Policy » [Userscript] Bulk Tag Editor » Post 19

Site and Policy » [Userscript] Bulk Tag Editor » Post 18

🐴
Magnificent Metadata Maniac - #1 Assistant
Solar Guardian - Refused to surrender in the face of the Lunar rebellion and showed utmost loyalty to the Solar Empire (April Fools 2023).
Non-Fungible Trixie -
Magical Inkwell - Wrote MLP fanfiction consisting of at least around 1.5k words, and has a verified link to the platform of their choice

IRL 🎠 stallion
I’ve tried this a couple times and it keeps insisting that it has “Completed with n errors” where n is the number of images I selected. However, Firefox (ESR under Debian) isn’t showing me anything at all about what those errors are when I view the console and try again.

Site and Policy » [Userscript] Bulk Tag Editor » Post 17

Site and Policy » [Userscript] Bulk Tag Editor » Post 16

Background Pony #BFC6
@rautamiekka
It can be done - I tweaked the script for myself with a “Select All” button - but I worry that’d make the script dangerously easy to misuse (maliciously or accidentally) so I was hesitant to suggest it be included normally…

Site and Policy » [Userscript] Bulk Tag Editor » Post 15

Site and Policy » [Userscript] Bulk Tag Editor » Post 14

Marker
My Little Pony - 1992 Edition
Wallet After Summer Sale -
Magnificent Metadata Maniac - #1 Assistant
Not a Llama - Happy April Fools Day!

Misanthrope
@rautamiekka
If you want a quicker way of selecting every image, you can paste document.querySelectorAll('.media-box__header').forEach(ele => ele.classList.add('media-box__header--selected')) into the console.

Site and Policy » [Userscript] Bulk Tag Editor » Post 13

Site and Policy » [Userscript] Bulk Tag Editor » Post 12

GlitchedWolf
Pixel Perfection - I still call her Lightning Bolt
Lunar Supporter - Helped forge New Lunar Republic's freedom in the face of the Solar Empire's oppressive tyrannical regime (April Fools 2023).
Elements of Harmony -
Non-Fungible Trixie -
Magnificent Metadata Maniac - #1 Assistant
Verified Pegasus - Show us your gorgeous wings!
Speaking Fancy - Badge given to members that help with translations
Happy Derpy! - For Patreon supporters

Moderator
Derpbooru Free Edition!?
@rautamiekka
When you click tag edit and all the score/comment boxes become red, you have to click on them and turn them green. All green/selected ones will get the tag edits.

Site and Policy » [Userscript] Bulk Tag Editor » Post 11

rautamiekka
Lunar Supporter - Helped forge New Lunar Republic's freedom in the face of the Solar Empire's oppressive tyrannical regime (April Fools 2023).
King Sombra - Celebrated the 10th anniversary of The Crystal Empire!
Elements of Harmony - Had an OC in the 2022 Community Collab
Magical Inkwell - Wrote MLP fanfiction consisting of at least around 1.5k words, and has a verified link to the platform of their choice
Speaking Fancy - Badge given to members that help with translations
Cool Crow - "Caw!" An awesome tagger
Magnificent Metadata Maniac - #1 Assistant
Preenhub - We all know what you were up to this evening~
Twinkling Balloon - Took part in the 2021 community collab.
My Little Pony - 1992 Edition

  • Windows 10 21H1 Enterprise x64
  • Google Chrome 95.0.4638.69 (Official Build) (64-bit).
  • Tampermonkey 4.13
  • Script version 1.1.1 from the primary install link in the OP.
Doesn’t seem to work properly for me:
On the search page with the Everything filter enabled, I click ‘Tag Edit’ in top right corner, add “oc name needed” to the ‘Tags to add’ and click ‘Apply’. It immediately says ‘Completed’ below the ‘Tags to add’ box, and redoing the search after 5mins and clicking any of the results shows the change wasn’t made.
I honestly dunno how to help, as I found no useful logs under C:\Users\REDACTED\AppData\Local\Google\Chrome\User Data\ even after enabling ‘Collect errors’ for Tampermonkey in Chrome extension settings and setting Tampermonkey’s own logging as Debug in its settings, which ain’t helped by Tampermonkey’s own docs being 1 of the most useless I’ve seen, if I didn’t miss anything.

Site and Policy » [Userscript] Bulk Tag Editor » Post 10

Marker
My Little Pony - 1992 Edition
Wallet After Summer Sale -
Magnificent Metadata Maniac - #1 Assistant
Not a Llama - Happy April Fools Day!

Misanthrope
even if it’s (a tiny bit) more network traffic
 
It doubles the amount of requests, in fact. :)  
But, because the tag fetching happens in the interim while waiting for the 5 seconds cooldown, with the exception of the first request, users will not be affected by any additional delays caused by these requests.
 
what the script would do in case the fetch of the image API has a non-promise-rejecting error
 
In most cases, a SyntaxError will be thrown by .then(resp => resp.json()) when it tries to parse the response. I know that querying a deleted image will get back a json response, but it’s unlikely that those images will be reachable from the search page.
 
in order to update the title and alt […] but that gets back into parsing and is just a nicety
 
Basically this. It’s cumbersome and just not something I particularly want to deal with, sorry.

Site and Policy » [Userscript] Bulk Tag Editor » Post 9

Background Pony #BFC6
@Marker  
Yes, at least upon first try, the update resolves the removing-aliases issue. Thanks!
 
Always glad when I can help. Using the API at the moment of submitting also means the tag list will be the most up-to-date, in case other users had made changes since loading the page, so that was probably the right decision in the end, even if it’s (a tiny bit) more network traffic.
 
I’m a little concerned what the script would do in case the fetch of the image API has a non-promise-rejecting error like a 500 - a condition you check in submitEdit but not getTagsFromId. Would one of the other lines, like if “image” or “post” objects are absent from the response, throw an error to catch? That’s getting out of my depth as an amateur. Is there any chance this could lead to inadvertently blanking an image’s tags? I guess that would be rejected for not having a required tag such as a rating. Or maybe, that’s why the POST data takes old tags as well as new tags, to take the difference on the server side…
 
Anyway…
 
I might have also left in the parts finding imageContainer, in order to update the title and alt so the tooltip reflects the changes without reloading the page, but that gets back into parsing and is just a nicety.

Site and Policy » [Userscript] Bulk Tag Editor » Post 8

Marker
My Little Pony - 1992 Edition
Wallet After Summer Sale -
Magnificent Metadata Maniac - #1 Assistant
Not a Llama - Happy April Fools Day!

Misanthrope
@Background Pony #BFC6  
Thanks for the detailed reply! That was incredibly helpful.  
You’re right regarding the footnote, that was an error on my part, good catch. Although in the end I elected to use the API method as it feels less prone to failure then parsing the title attribute, and easier to maintain compatibility with Twibooru.  
The script has been updated, I hope this resolves your issue.

Default search

If you do not specify a field to search over, the search engine will search for posts with a body that is similar to the query's word stems. For example, posts containing the words winged humanization, wings, and spread wings would all be found by a search for wing, but sewing would not be.

Allowed fields

Field SelectorTypeDescriptionExample
authorLiteralMatches the author of this post. Anonymous authors will never match this term.author:Joey
bodyFull TextMatches the body of this post. This is the default field.body:test
created_atDate/Time RangeMatches the creation time of this post.created_at:2015
idNumeric RangeMatches the numeric surrogate key for this post.id:1000000
myMetamy:posts matches posts you have posted if you are signed in. my:posts
subjectFull TextMatches the title of the topic.subject:time wasting thread
topic_idLiteralMatches the numeric surrogate key for the topic this post belongs to.topic_id:7000
topic_positionNumeric RangeMatches the offset from the beginning of the topic of this post. Positions begin at 0.topic_position:0
updated_atDate/Time RangeMatches the creation or last edit time of this post.updated_at.gte:2 weeks ago
user_idLiteralMatches posts with the specified user_id. Anonymous users will never match this term.user_id:211190
forumLiteralMatches the short name for the forum this post belongs to.forum:meta