Script Summary: Adds a variety of tweaks to Danbooru, each of which can be easily disabled. Updated whenever I think of something useful/interesting.
To make good use of this script, you must adjust the options at the top of the source code yourself. Each tweak can be easily disabled by commenting out the appropriate function call at the top. Some functions (as indicated below) are disabled by default. Additional documentation can be found above each function's definition.
These tweaks are fully compatible with Danbooru Show Child Thumbnails and Unlimited Paginator Works.
Be sure to save the function calls elsewhere before updating the script, to prevent losing your custom settings.
Functions:
- updateCheck(): Checks for script updates.
- arrowKeyNavigation(enabledPages): Use arrow keys to go to next/previous page when such pages exist and the URL matches the enabledPages regex (default: pool and Popular By pages, so as to not interfere with Endless/Unlimited scripts). Paginated pages wrap around.
- blacklistTags(blacklist): (Default: DISABLED) Blacklist implementation that replaces images (full and thumbnail) with links labeled with the first tag they matched in the blacklist regex (default: dummy tags). Clicking the link/image alternates between the two; translation notes appear every other time the image is displayed. User, rating, and score can be included in the blacklist, but Danbooru Show Child Thumbnails adds a space after the colon for those. This only works with thumbnails that have title attributes.
- addToNavbar(): Adds upload/IQDB (image search)/trac links to navbar and changes order of Tags from "date" to "count".
- addToSubnavbar(): Adds Popular By Day/Week/Month links to subnavbar, removing the old "Popular" link if present.
- insertTagSearch(): Inserts a tag searchbox if one is not present.
- addMetatags(tagList): Adds a list of metatags below existing tag lists, complete with +/- links. See http://danbooru.donmai.us/help/cheatsheet for the full list of possible metatags.
- changePlusMinusLinks(): Use the +/- links next to tags in the taglist (which appear for normal tags for Privileged+ users) to add/remove/negate tags from the tag search box. Tags cannot be added or negated more than once.
- giveThumbnailsScores(appendScore, appendFavcount): Appends images' scores and favorite counts below their thumbnails if appendScore (default: true) and appendFavcount (default: both false) are true, respectively.
- styleTags(tags, style): (Default: DISABLED) Gives all tags matching the tags regex (default: a list of translation-related tags) the style attribute style (default: 'color:black'). This function can be called multiple times to apply multiple styles, but overlaps in the tags parameters are not supported.
- addPostLinkToPoolMembers(): Adds a "Post" link to pool navbars (in post pages) that runs a tag search for the members of that pool.
- changeSourceStat(): Links the "Source:" stat to a tag search for the source url (removing anything after the last '/') and renames pixiv source links to "(pixiv) /[artist id]/".
- findLostArtists(resultLimit, scrollDown): (Default: DISABLED) For posts with a source URL but no artist tag: Runs an automatic "Find artist" query and displays up to resultLimit (default: 3) results below the Source stat. Also counts how many other posts have the same source (removing anything after the last '/'). If scrollDown is true (default: false), the page will automatically scroll down to the Source stat.
- styleUserLevels(refreshDays, ...): Applies style attributes (default: various colors) to links to user pages depending on the type of user (running from "Admin" to "Blocked"). Users' levels are cached as Greasemonkey script variables; every refreshDays days (default: 2), this cache is purged.
- artistPageSourceSearch(pixivOnly): Adds links to source searches next to either all URLs or just pixiv image URLs on an artist page, depending on whether pixivOnly is true (default: false). Many of the links added by the former will encompass multiple artists (e.g. 'source:http://www.pixiv.net').
- sizeLinkSampleSwitcher(): Makes the size link bold if there is a sample version. Clicking the link alternates between sample size and full size.
- addHiddenDirectLinks(): Adds hidden links to the full sizes of thumbnails, for use with mass-downloading tools.
- uploadPageFixer(widthScale): For upload pages of the form 'http://danbooru.donmai.us/post/upload?url=[image URL]': Resizes the image on the upload page to widthScale (default: 0.9) of the window width, removes the line about whether a pixiv artist page exists entirely (since it's usually wrong), and adds the pixiv artist to the tag box if the auto-Find Artist query returned exactly one result.
- historyColumns(minTagHistory, removeRegex, centerRegex, rightRegex): If minTagHistory (default: true), the widths of all columns in tag history pages except Tags are reduced. Any columns whose headers match removeRegex (default: IP Address, Parent, Rating, Source), centerRegex (default: [nothing]), and rightRegex (default: Tags) are removed, center-aligned, and right-aligned, respectively.
- postSearchLimitBreak(limit): (Default: DISABLED) Modifies links to post searches (plus the search box) to show limit (default: 40) posts per page.
- addTagSubscription(...): (Default: DISABLED) Mimics the Priv+ tag subscription feature, displaying the combined results of any number of post/comment/note searches (intersection or union) on your user page. Some restrictions apply, see source code for details. Three example usages have been provided; the first two show you which uploads of yours have been recently commented/translated.
- precisionTime(precision, offset): (Default: DISABLED) Changes the dates for post uploads and comments depending on precision (default: 2): negative numbers insert a timestamp adjusted to your local time, while positive numbers add that many decimal places. Time is adjusted by offset (default: 0) hours. Depending on how you observe Daylight Savings, the new times may be slightly off.
- subscriptionSpaces(): Replaces underscores in tag subscription titles with spaces.
- refreshOnTimeout(pathRegex, delay): Refreshes pages matching pathRegex after delay ms (default: 5000 ms).
- poolOrderLinks(): Adds links to increase/decrease the order number of all pool posts at and below each link.
- rightFocusTagEdit(): Sends cursor to end of tag box on post/show pages when Edit is clicked.
- dtextReplace(...): Replaces text in DText textareas and link names. The default use replaces various full URLs with DText or pseudo-DText shorthand.
- findForumPosts(titleLen, showProgress, offset): Changes the subnavbar "Parent" link when viewing forum posts to display the title (truncated to titleLen (Default: 100) chars) and point to the page they come from. If showProgress is true (Default: true), periods are appended to the link until the page is found. The links in the dates below users' names in forum posts are similarly changed. Clicking these links sends you to that exact post, offset by offset (Default: -10).
- previewFix(): Fixes bug in Preview panel when link at end of one line is followed by something else on the next.
> Added textReplace(), which operates on link names and DText-enabled textareas. The default use replaces many different full URLs (when inserted at the very end, in the case of textareas) with their DText or pseudo-DText shorthand. For instance, '
http://danbooru.donmai.us/post/show/881519/2girls-apron-bowtie-brown_eyes' becomes 'post #881519' and 'http://www.pixiv.net/member_illust.php?mode=manga_big&illust_id=18886695&page=2' becomes '"pixiv #18886695/p2":http://www.pixiv.net/member_illust.php?mode=manga_big&illust_id=18886695&page=2' (which displays as 'pixiv #18886695/p2').
> Added findForumPosts(), which changes "Parent" link in the subnavbar when viewing individual forum replies to point to the page they come from and display the title of the thread. There is a variable delay before the link is changed.
> Added previewFix() to fix a bug in the Preview panel
> findListArtsts() and the favcount portion of giveThumbnailsScores() are now disabled by default.
> giveThumbnailsScores(true,false) + giveThumbnailsScores(false,true) = giveThumbnailsScores(true,true).
> Fixed sizeLinkSampleSwitcher() not toggling.
> blacklistTags() now has each thumb list all of the tags that matched the blacklist, not just one. Note that the format of the blacklist parameter has changed.
2012-01-20:
> Added rightFocusTagEdit().
2012-01-18:
> Added more error checking for functions running API queries.
> Added something to addTagSubscription() to specially reset subs involving your own favs whenever a post is added/removed. An example "Recent Favorites" call is also commented out at the top.
> Fixed subscriptionSpaces() not activating for /user/show?name= URLs
> Fixed the source link in changeSourceStat() to work with the source metatag's new behavior.
2011-09-24:
> Rewrote addTagSubscription(). Now you can find the intersection or union of any number of queries to the post, note, and comment indexes (only post if union). See source code for details. Added additional example usage.
> Removed dayDelay from update checker.
2011-08-23:
> Fixed various links using http://danbooru.donmai.us/ when on hijiribe or sonohara.
> Readded refreshOnTimeout(), now with a regex parameter to limit what pages it triggers for
> Added poolOrderLinks().
> Removed addNoteShortcut() since this script is better.
2011-07-13:
> Added subscriptionSpaces().
> Made the +/- links added by addMetatags() work like those for normal tags when changePlusMinusLinks() is disabled.
2011-07-01:
> uploadPageFixer(): Fixed script-breaking typo
> precisionTime(): Added offset parameter
> Made blacklistTags() and precisionTime() disabled by default
2011-06-21:
> precisionTime(): Corrected timezone bug. Times may still be off depending on how you observe Daylight Savings.
> addMetatags(): Moved the list of metatags into the parameter list.
2011-06-17:
> Added working substitutes for the Greasemonkey API. Everything except the update checker ought to work on other browsers now.
2011-06-11:
> Added precisionTime().
> uploadPageFixer(): Fixed the artist entry modifier to work when Danbooru's "always load pixiv info" is active.
2011-04-19:
> Added status:any to the searches performed/provided by artistPageSourceSearch(), changeSourceStat(), and findLostArtists().
2011-04-01:
> blacklistTags(): Your own uploads are now exempt from the blacklist.
> addMetatags(): Added order:rank and status:any.
> styleUserLevels(): Added support for the new Builder user level.
> Improved support for browsers besides Firefox. Several tweaks won't work correctly outside Firefox, but the script shouldn't break completely anymore.
2011-02-11:
> arrowKeyNavigation(): Fixed case where pools aren't switched when the referring pool runs out.
> addTagSubscription(): Fixed thumbnail post queries not completing for Member-level accounts.
> Added postSearchLimitBreak(): This inserts the limit parameter into all post search links (and the search box), allowing you to change the number of posts per page. Disabled by default.
> Added addTagSubscription(): Mimics the "tag subscription" feature available to Priv+ by finding the intersection of a post search and a search that returns post IDs and displaying the top results on your user page. Study the source code documentation and you might figure out how to use it. The two disabled calls to it at the top will show you posts uploaded by you that were commented/translated in the last day or so. Those two uses were the reason this was written, and they're very inefficient--80+ pages of comments to reliably go back a day...
> arrowKeyNavigation(): Added a referrer check so you don't switch pools if you hit a post in more than one... unless you come across two posts that are back-to-back in the same two+ pools.
> styleTags(): Added support for html-encoded chars and overlapping tag sets. Note the change in the regex parameter's format.
> uploadPageFixer(): Removed the nagging about incorrect pixiv URLs and updated the documentation.
> Various optimizations that shouldn't affect the end result (XPath tweaks, replacing eval with JSON.parse(), etc...).
> insertTagSearch(): Fixed script breaking on http://danbooru.donmai.us/static/more.
> addNoteShortcut(): Fixed problem with the edit boxes of notes placed on sample images. The edit box is still off from the cursor, but not as wildly off as it sometimes used to be.
> uploadPageFixer(): Artist entry line is now removed for all cases, not just FindArtist == 1.
> findLostArtists(): Removed brute-force FC2 search. Too slow, and running it every single time an FC2 post is viewed is a waste.
> styleUserLevels(): User levels are now cached as Greasemonkey script variables and reloaded periodically instead of for every page.
> Removed refreshOnTimeout(): Useless at best, and quite annoying when the failure occurs on a data submission.
> Added addNoteShortcut(): Use a keyboard shortcut to add new notes. Also forces notes to appear on image at the closest point to where the cursor last moved.
> Added historyColumns(): Removes useless columns from history pages, and changes the width and alignment of others. By default, "IP Address" is removed because it's always blank for most users. Parent, Rating, and Source are removed because that information is already contained in the Tags column and overly long sources in Source are capable of pushing Tags out of sight.
> Various non-functional formatting changes.
> uploadPageFixer() fix: Something broke the artist tag being added and the artist entry notice being removed.
> Removed danbooruSafebooruSwitcher(); I don't think that site is ever coming back...
> addHiddenDirectLinks() fix: Hidden div was taking up space and creating a horizontal scrollbar on certain pages.
> uploadPageFixer() fix: Artist entry notice was not being completely removed if the entry was found with multiple URLs.
> uploadPageFixer() fix: URL encoded version of the artist tag was being added to the tag box instead of the actual tag.
> uploadPageFixer() addition: Complaint about http://www.pixiv.net/member* style links. Caps lock is cruise control for cool.
> changeSourceStat() addition: If the image source is of a certain form (e.g. *pixiv.net/img/aaaaaa/######.jpg?###### and *pixiv.net/img/aaaaaa/######_s.jpg), Danbooru screws up the "medium/manga mode" source URL. Fixed.
> Fixed bug that was causing addHiddenDirectLinks() to blank all the comments in the comment search.
> Modified uploadPageFixer() again to force loading of pixiv information every time and add the artist tag to the tag box if Find Artist returned one pixiv result.
> New function "updateCheck(dayDelay)"--the generic script update checker, modified to notify the user [dayDelay] days after an update is detected, in case I have to go back and make an extra fix or two after updating the script.
> Improved uploadPageFixer() now corrects users that try to upload small/medium versions of pixiv images and replaces the useless "no profile image" image link with the URL in the source field.
> Added the direct URLs to Danbooru's two servers (hijiribe and sonohara) to the includes list.
> New function "addHiddenDirectLinks()" adds hidden links to the full sizes of thumbnails, for use with download utilities like DownThemAll.
> New function "uploadPageFixer(widthScale)" applies to the 'http://danbooru.donmai.us/post/upload?url=[image URL]'--which is what the upload bookmarklet gets you. Scale factor is changed to [widthScale] of screen width, pixiv image URLs contained in the "create artist" link are corrected from '/profile/' (useless for Find Artist) to '/img/', and the line about whether an artist page exists is removed if Find Artist returned exactly one result.
> Changed artistPagePixivSourceSearch() to artistPageSourceSearch(pixivOnly); search links are now added to all URLs unless pixivOnly is true. This adds many searches that aren't specific to a single artist (e.g. 'source:http://www.pixiv.net'), but oh well. Search links also now appear next to URLs instead of below them.
> Added third parameter to findLostArtists() to turn the brute force lookup of blogs of FC2 images on/off. Off by default.
> Disabled danbooruSafebooruSwitcher, since safebooru.donmai.us doesn't look to be coming back any time soon.
> Corrected artistPagePixivSourceSearch's search url; apparently pixiv images from the same artist can come from different img##.
> Fixed "(pixiv) /[artist id]/" not displaying if the number in "img##" was less than 10.
> Added a function to refresh the page automatically upon timeout.
> For images from fc2.com, findLostArtists() also does a brute-force search for the corresponding blog's main page.
> Results from findLostArtists's "Find Artist" query point to the artist page instead of a tag search.
> Stopped the sample switcher function from causing the page to hang.
> Fixed bug with last change; script was halting early. Good thing there wasn't anything below tha...wait a minute:
> Put the recursion declaration where it belongs. I'm really surprised it went unnoticed for so long--it ought to have messed up Unlimited Paginator Works and Endless Danbooru Comments.
> Size link on post pages is bold if a sample exists. Clicking it causes the image to alternate between sample and full size.
> Danbooru now adds a post link to pool pages on its own, so removed that bit from the script.
> Added "order:change_desc" to metatag list.
> Fixed findLostArtists() to work with the latest changes to the artist API.
> Added a source search link to pixiv image URLs on artist pages.
> The tag-type metatags ("artisttagcount", etc...) were just renamed; addMetatags() modified accordingly.
> Tweaked user style function to accommodate the new "Test Janitor" level. Colors as arbitrary as always; taste the rainbow.
> Fixed script-breaking bugs caused by the new "Approver" stat.
> Fixed a minor bug that was assigning incorrect styles to some user names when adding/removing favorites.
> Fixed the delay in styling user links (except when adding/removing favorites) and added a one second timeout check just in case.
> Styles for user page links are properly reapplied after adding a post to favorites (or removing it). For this special case (linking by name instead of ID), however, if the search for the username does not turn up an exact match in the first 20 results, the user will be treated like a normal Member.
> Modified blacklist call so that posts with tags with quotes (all... two of them) aren't skipped.
> The blacklist now checks rating, score, and user for full images (thumbnails already worked). However, thumbnails created by the Danbooru Show Child Thumbnails and Endless Danbooru Pages scripts don't handle these quite the same; see this thread for the modifications to the former (the relevant section is the same for both, though).
> The findLostArtists function now always does a source search, not just when more than one artist matches the URL.
> New function: Ability to apply different styles to links to user pages based on level. This may take a few seconds to complete, however. By default, every type gets a different color (regular members stay the same). Also, adding a post to your favorites (or removing it) undoes the styling, because the links then switch to name instead of ID.
> Fixed score/favcount function to work with the Danbooru Show Child Thumbnails script.
> Various minor revisions, mostly related to maintaining proper variable scope (which was suddenly breaking the "find artists" function).
> Favorite counts are now appended below thumbnails, next to the score. Since separate queries must be made for each image, there is a slight delay before these appear. Score and favorite count can be turned off individually.
> Custom tag coloring now applies to everywhere the default tag types are colored.
> Arrow key navigation for the Popular By pages is now enabled by default (previously only enabled for pool pages). As always, the other pages can be enabled by modifying the regex parameter to something like /./.
> When findLostArtists triggers, the page scrolls to Statistics rather than by a set amount. The offset parameter is now a boolean that turns this scrolling on/off.
> The blacklist bug appears to be fixed already, so I've removed the fix from last time.
> The amount the page scrolls down when findLostArtists triggers is now a parameter.
> All thumbnails hidden by Danbooru's blacklist are now shown, as a workaround to an annoying bug that hides thumbnails that appear more than once on a page (which can occur on user pages).
> All tweaks are now functions, with their calls all at the top of the script for easy enabling/disabling. Several also take parameters for easier customization.
> Modified code to work with my new Unlimited Paginator Works script.
> If a post has a source URL but no artist tags, a "Find artist" query is automatically run, with the first few results shown below the Source stat. Clicking on one of the results will open the edit box and add the tag; clicking the tag again will remove it. If there is more than one result, the number of other posts with that source is also displayed.
> Linkified the "source" stat, and changed how pixiv sources are displayed (now as "(pixiv) /[artist identifier]/").
> Fixed a bug in the blacklist that would hide translation notes if one was also using the Show Child Thumbnails script and a child post matched the blacklist.
> Added a Posts link in the pool navbar in posts that runs a tag search for posts in that pool.
> Threw in the ability to change a set of tags to whatever color you want, but left it disabled because I don't use it. Remove the "/*" and "*/" around the relevant section to turn it on; changing the tags and color should be obvious.
> A slight Danbooru change broke arrow navigation for pools again. Unbroken now.
> Danbooru changed how pool history works, so my "color-coded history" no longer applies. Removed.
> Added the new metatags for tag-type counts to the list. Having them call up prompts for values when clicked (and modifying the +/- functionality accordingly) was too troublesome, so I settled for default values like I did with the score metatag. The "?" links for the metatags now point to the Danbooru cheat sheet.
> Images' scores are now listed below their thumbnails.
> The blacklist script now works without any need to modify the Endless and Show Child Thumbnails scripts. Undo the formerly-required modifications to those before using this version.
> Fixed arrow key navigation for pool posts to work with the new style of pool notice.
> Pool history is now color-coded and linked. Additions = green, deletions = red+strikethrough, reordering = purple. Because the script hangs on very large pools/histories, a timeout is built in. Default is 1 second, but this can be changed in the source.
> Added a Posts link to pool pages in the subnavbar that runs a tag search for posts in that pool.
> Fixed +/- code so that it includes "Subscribed Tags".
> Fixed a bug where the lack of a subnavbar on the new random post page caused the code to halt early.
> Arrow key navigation no longer triggers when a text or input field has focus.
> Translation notes for images hidden by the blacklist now toggle on and off with the image: link -> image w/ notes -> link -> image w/o notes.
> Added a check to the +/- code so it won't break for regular users before it gets to the added metatags... probably.
> Changed include statements to prevent it from triggering in the image search with images already hosted by Danbooru.
> Rewrote the +/- code and cleaned up a little elsewhere; functionality remains the same.
> Switching pages with the arrow keys now works with the popular by day/week/month pages and member posts of pools.
> Switch between Safebooru and Danbooru versions of a page with Ctrl+X. This is particularly useful for the popular pages.
> This script now triggers for both Danbooru and Safebooru.
> Added navigating pages with left/right arrow keys (wraps around). Since I use the Endless scripts, comment and post pages are ignored.
> Also added a link to the Trac in the navbar.
> Cleaned up a bunch of the coding, now that I have a better idea of what I'm doing.
> Added Popular By Day/Week/Month links to the beginning of the subnavbar.
> Made the blacklist system far more complicated. Blacklisted items now alternate between the link and the original image/thumbnail when you click on them. See its section in the source for more info and easy instructions on how to add it to the other Danbooru scripts.
> Added some metatags to the tag list, wherever it appears. More metatags can be added easily by copying the template.
> Fixed bug where " in the tag would break the +/- code.
> Added +/- link change.
> Avoiding brute force document.body.innerHTML replacing so the script doesn't break the translation notes, among other things. Also added a few other minor features. Custom blacklist made because I didn't like how Danbooru handled it last time I checked; just modify the "var blacklist" line at the top of the script. Though using this means you also have to customize the Endless scripts so that this blacklist applies to the additional posts.



