Donmai

Add-to-blacklist CSS/bookmarklet possible?

Posted under Bugs & Features

I've found myself adding a lot of tags to my Blacklist lately, which has me wondering if it could be made simpler. I saw an old forum post mentioning that the JSON/XML API can be used to look at the blacklist, so it seems like it might be possible; but I'm not familiar with that sort of scripting, and I don't see the Blacklist mentioned in help:api

Probably the most convenient way I could see this working would be a Userscript to make an add-to-blacklist button next to each tag in a selected category or categories (Copyrights, Characters, Artist, General), e.g.:
? B + – ookuma (nitroplus) 218
Clicking B would add ookuma_(nitroplus) to a new line at the end of the Blacklist.

My other thought for how such a thing might work would be a Bookmarklet that would add the contents of the current Search to a new line at the end of the Blacklist.

If any of the awesome scripters around here could put something like that together, or point me in the right direction for how to make such a thing, or tell me that it's impossible, I'd greatly appreciate it.

It is possible with a JSON/XML request. I just ran an HTTP sniffer, and the following is the data of interest that got sent in a POST to my user ID instance

URL was: http://danbooru.donmai.us/users/23799
HTTP method was: POST
Data was: user[blacklisted_tags]=yaoi\r\nfurry\r\nguro+\r\nfuta_with_male\r\nvore\r\nbestiality+\r\nprolapse\r\nrating:explicit\r\ntest

Note: The "\r\n" are carriage returns BTW. Also in addition to the above, the browser sends my username plus my authenticity token.

Not sure if browser user scripts are capable of sending HTTP requests like the above...? It's definitely possible with a programming language like C, or a scripting language like Python though...

Edit

Looking at the above again, I forgot to mention that the "+" represents a space. I checked my blacklist tags again, and sure enough, there were some hidden spaces at the end of some of those tags.

Also, I'm not sure if there's a method to query the black listed tags through the API. The following is an example of a user query.

Show

{"id":23799,"name":"BrokenEagle98","level":32,"inviter_id":13392,"created_at":"2007-12-31T04:13:18.602Z","base_upload_limit":50,"post_update_count":86294,"note_update_count":22313,"favorite_count":202,"post_upload_count":5698,"wiki_page_version_count":820,"artist_version_count":302,"artist_commentary_version_count":1142,"pool_version_count":1300,"forum_post_count":553,"comment_count":1118,"appeal_count":2,"flag_count":11,"positive_feedback_count":6,"neutral_feedback_count":1,"negative_feedback_count":1,"is_banned":false,"can_approve_posts":false,"can_upload_free":true,"is_super_voter":false,"level_string":"Builder","remaining_api_hourly_limit":19999}

As can be seen in the above query, there is no mention of my blacklisted tags (or any other of my user settings) even though I'm the one querying, and there shouldn't be any reason not to show my own settings to myself.

Updated

Try this bookmarklet. It will blacklist whatever is in the search box. Highlight it and drag and drop to your bookmarks bar to use:

javascript:$.post("/users/" + $("meta[name=current-user-id]").attr('content'), { _method: "patch", "user[blacklisted_tags]": $("meta[name=blacklisted-tags]").attr('content').split(',').concat([$("#tags")[0].value]).join("\n") });

Very quick and dirty, tested for all of ten seconds, so probably buggy. It'd be more convenient as a userscript but that'd be more involved. I have been itching though to do some stuff with userscripts lately, so maybe I'll have a go at it this weekend. (namely: I've always wanted to have a dropdown menu next to each tag in the tag list with options for various frequent tasks: remove tag from post, add/remove tag from blacklist, add to saved searches, etc).

And BrokenEagle, you're right that blacklisted tags aren't returned by the API. They could be added to the API easily enough though. For those playing at home: pretty sure :blacklisted_tags just needs to be added here. TBH I see no reason not to include all of the user's personal settings in the API.

BrokenEagle98 said:

As can be seen in the above query, there is no mention of my blacklisted tags (or any other of my user settings) even though I'm the one querying, and there shouldn't be any reason not to show my own settings to myself.

issue #1551. I'll probably get to fixing it soon.

1