From ffe3313f4ccf60e66817d25f5b25fb0f8b47d3d2 Mon Sep 17 00:00:00 2001 From: Moebius-Strip Date: Sat, 15 Feb 2014 15:51:04 -0500 Subject: [PATCH 01/10] Initial plans for fixing hidden post display File information is being removed from the API so alternatives will have to be used. For missing thumbnail info, I'm just replacing them with a "Hidden" thumb placeholder. For actual posts, I'm using alternative information methods and completely discontinuing use of the API. I'm thinking I'll add support for "status:banned" to the borders portion. --- better-better-booru.user.js | 112 ++++++++++++++++++++---------------- 1 file changed, 64 insertions(+), 48 deletions(-) diff --git a/better-better-booru.user.js b/better-better-booru.user.js index a810d78..fb9428c 100644 --- a/better-better-booru.user.js +++ b/better-better-booru.user.js @@ -1,5 +1,5 @@ // ==UserScript== -// @name better_better_booru +// @name better_better_booru_test // @author otani, modified by Jawertae, A Pseudonymous Coder & Moebius Strip. // @description Several changes to make Danbooru much better. Including the viewing of loli/shota images on non-upgraded accounts and more. // @version 6.0.2 @@ -222,12 +222,8 @@ function injectMe() { // This is needed to make this script work in Chrome. fetchJSON(gUrl.replace(/\/notes\/?(?:\?|$)/, "/notes.json?") + limit, "notes"); } } - else if (mode === "post") { - if (!needPostAPI()) - fetchInfo(); - else - fetchJSON(gUrl.replace(/\/posts\/(\d+).*/, "/posts/$1.json"), "post"); - } + else if (mode === "post") + fetchInfo(); else if (mode === "popular") { if (numThumbs !== thumbnail_count_default || direct_downloads) fetchJSON(gUrl.replace(/\/popular\/?/, "/popular.json"), "popular"); @@ -322,66 +318,77 @@ function injectMe() { // This is needed to make this script work in Chrome. function fetchInfo() { // Retrieve info in the page. (Alternative to fetchJSON) - var infoLink = document.evaluate('//aside[@id="sidebar"]/section/ul/li/a[starts-with(@href, "/data/")]', document, null, 9, null).singleNodeValue; - var infoHref = infoLink.href; - var infoHrefValues = /data\/(.+?)\.(.+?)$/.exec(infoHref); - var md5 = infoHrefValues[1]; - var ext = infoHrefValues[2]; - var infoSection = infoLink.parentNode.parentNode; - var imgHeight = 0; - var imgWidth = 0; - var hasLarge = false; - var childNotice = document.getElementsByClassName("notice-child"); - var img = document.getElementById("image"); var imgContainer = document.getElementById("image-container"); + var img = document.getElementById("image"); var object = imgContainer.getElementsByTagName("object")[0]; - var infoTextDim = /\((\d+)x(\d+)\)/.exec(infoLink.parentNode.textContent); - var postId = fetchMeta("post-id"); + var childNotice = document.getElementsByClassName("notice-child"); + var resizeNotice = document.getElementById("image-resize-notice"); + var postId = imgContainer.getAttribute("data-id"); + var infoSection = document.getElementById("score-for-post-" + postId).parentNode.parentNode; + var md5 = ""; + var ext = ""; + + var infoLink = document.evaluate('//aside[@id="sidebar"]/section/ul/li/a[starts-with(@href, "/data/")]', document, null, 9, null).singleNodeValue; + var twitterInfo = fetchMeta("twitter:image:src"); - if (img) { // Regular image. - imgHeight = Number(img.getAttribute("data-original-height")); - imgWidth = Number(img.getAttribute("data-original-width")); - hasLarge = (imgWidth > 850 ? true : false); + if (infoLink) { + var infoHrefValues = (infoLink ? /data\/(.+?)\.(.+?)$/.exec(infoLink.href) : null); + md5 = infoHrefValues[1]; + ext = infoHrefValues[2]; } - else if (object) { // Flash object. - imgHeight = Number(object.getAttribute("height")); - imgWidth = Number(object.getAttribute("width")); - hasLarge = false; + else if (twitterInfo) { + var twitterInfoValues = (twitterInfo ? /(?:data\/sample\/sample-|data\/)(.+?)\.(.+?)$/.exec(twitterInfo) : null); + md5 = twitterInfoValues[1]; + ext = twitterInfoValues[2]; } - else if (infoTextDim) { // Displayed content removed but the link still exists. - imgHeight = Number(infoTextDim[2]); - imgWidth = Number(infoTextDim[1]); - hasLarge = (imgWidth > 850 ? true : false); + + if (!md5) { // Irregular hidden files do not provide enough info to be found (bmp, rar, zip, etc). + danbNotice("Better Better Booru: Due to a lack of provided information, this post cannot be viewed.", "error"); + bbbStatus("error"); + return; } - else { // Manual download. - imgHeight = null; - imgWidth = null; - hasLarge = false; + + var imgHeight = Number(imgContainer.getAttribute("data-height")); + var imgWidth = Number(imgContainer.getAttribute("data-width")); + var hasLarge = (imgWidth > 850 && ext !== "swf" ? true : false); + + if (hasLarge && !infoLink) { // Test for the original image file extension if it is unknown. + if (resizeNotice) + ext = /(?:data\/sample\/sample-|data\/).+?\.(\w+?)$/.exec(resizeNotice.getElementsByTagName("a")[0].href)[1]; + else { + var testExt = ["jpg", "png", "gif", "jpeg"]; + + for (var i = 0, numExt = testExt.length; i < numExt; i++) { + if (isThere("/data/" + md5 + "." + testExt[i])) { + ext = testExt[i]; + break; + } + } + } } var imgInfo = { id: Number(postId), file_ext: ext, md5: md5, - url: infoHref, - fav_count: Number(document.getElementById("favcount-for-post-" + postId).textContent), - has_children: (document.getElementsByClassName("notice-parent").length ? true : false), - parent_id: (childNotice.length ? Number(childNotice[0].children[0].href.match(/\d+/)) : null), - rating: /Rating:\s*(\w)/.exec(infoSection.textContent)[1].toLowerCase(), - score: Number(document.getElementById("score-for-post-" + postId).textContent), - tag_string: fetchMeta("tags"), - pool_string: fetchMeta("pools"), - uploader_name: /Uploader:\s*(.+?)\s*ยป/.exec(infoSection.textContent)[1], + fav_count: Number(imgContainer.getAttribute("data-fav-count")), + has_children: (imgContainer.getAttribute("data-has-children") === "true" ? true : false), + parent_id: (imgContainer.getAttribute("data-parent-id") ? Number(imgContainer.getAttribute("data-parent-id")) : null), + rating: imgContainer.getAttribute("data-rating"), + score: Number(imgContainer.getAttribute("data-score")), + tag_string: imgContainer.getAttribute("data-tags"), + pool_string: imgContainer.getAttribute("data-pools"), + uploader_name: imgContainer.getAttribute("data-uploader"), is_deleted: (fetchMeta("post-is-deleted") === "false" ? false : true), is_flagged: (fetchMeta("post-is-flagged") === "false" ? false : true), is_pending: (!document.getElementById("pending-approval-notice") ? false : true), - image_height: imgHeight, - image_width: imgWidth, + image_height: (imgHeight ? imgHeight : null), + image_width: (imgWidth ? imgWidth : null), has_large: hasLarge, file_url: "/data/" + md5 + "." + ext, large_file_url: "/data/sample/sample-" + md5 + ".jpg", preview_file_url: (!imgHeight || ext === "swf" ? "/images/download-preview.png" : "/ssd/data/preview/" + md5 + ".jpg"), - exists: true + exists: (img || object ? true : false) }; delayMe(function(){parsePost(imgInfo);}); // Delay is needed to force the script to pause and allow Danbooru to do whatever. It essentially mimics the async nature of the API call. @@ -523,6 +530,7 @@ function injectMe() { // This is needed to make this script work in Chrome. var post = formatJSON(posts[i]); var outId = ""; var thumb = ""; + var hiddenImg; // Don't display loli/shota/toddlercon/deleted if the user has opted so and skip to the next image. if ((!show_loli && /\bloli\b/.test(post.tag_string)) || (!show_shota && /\bshota\b/.test(post.tag_string)) || (!show_toddlercon && /\btoddlercon\b/.test(post.tag_string)) || (!show_deleted && post.is_deleted)) { @@ -534,6 +542,14 @@ function injectMe() { // This is needed to make this script work in Chrome. continue; } + // Provide hidden images with a placeholder. (Hotfix) + if (!post.preview_file_url) { + if (!hiddenImg) + hiddenImg = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJYAAACWCAIAAACzY+a1AAAefElEQVR4Xu2Yva8md3XHEe8giBAgUYJEbAAhWiT+AzoiUWIUmgAIUYQWaFLaDQVdEBWpQKKhjF2RIkhOAUayQ7z3rtd42fUujpcY7I1JZu73PJ/PzByN5pm9duJFz3lmfr/z8j3vc62FN/3DfU4nGlf4P/ctnegvcIWnFZ7otMITnVZ4otMKTyv885+Hd7zrzDFIYQMJEnM4Iow0leNdppzgwZExl8Yklw3IBNHoG1EmrCUbnRMPz7xgTVTpVXSkETPN6tpCcoiz04II0FMUWFc4COPjVQiTOrRC0WymZpaSxSdutBYZh3gQA3DiBgEVOpm4GC4/sNRheYW0kCAqkK3LxB0wcfhGCBJ/W7WSaUF4ayOQceffqcU5ywJMV8hyGJqdI8ORA73xl2YqwAQKUsY7Sg+nSQxDzsGWoNkvRDFIL7iVykQbymoYLoy+ers4FTL0Ha1SdUs26LDCVyNeggyxDXydkwkSBnvpci5fcld7I3lp0tpX+Oqr0b86HtyjEk3Zw74aTrTj0rtuoH2qc1H3BIyXSr0TkBJbRuPTMoZwDZkHH+xkJYVT4aDATglgq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c6rfBEpxWeVnii0wpPdFrhiU4rPK3wRKcV3q90WuGJTis80WmFpxXe53Si/wVkMsbi+PBDegAAAABJRU5ErkJggg=="; + + post.preview_file_url = hiddenImg; + } + // eek, huge line. thumb = '
' + post.tag_string + '
'; From 6f50b47391a7632857b3d3a807f20e0d60aab4cc Mon Sep 17 00:00:00 2001 From: Moebius-Strip Date: Sat, 15 Feb 2014 21:03:13 -0500 Subject: [PATCH 02/10] Greasemonkey icon + "status:banned" support * Added a simple Greasemonkey icon that shows up in the script list. * Added custom tag border support for banned posts. --- better-better-booru.user.js | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/better-better-booru.user.js b/better-better-booru.user.js index fb9428c..8c3c019 100644 --- a/better-better-booru.user.js +++ b/better-better-booru.user.js @@ -11,6 +11,7 @@ // @exclude http://trac.donmai.us/* // @run-at document-end // @grant none +// @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAAAAABWESUoAAAA9klEQVQ4y2NgGBgQu/Dau1/Pt/rhVPAfCkpwKXhUZ8Al2vT//yu89vDjV8AkP/P//zY0K//+eHVmoi5YyB7I/VDGiKYADP60wRT8P6aKTcH//0lgQcHS//+PYFdwFu7Ib8gKGBgYOQ22glhfGO7mqbEpzv///xyqAiAQAbGewIz8aoehQArEWsyQsu7O549XJiowoCpg4rM9CGS8V8UZ9GBwy5wBr4K/teL4Ffz//8mHgIL/v82wKgA6kkXE+zKIuRaHAhDQATFf4lHABmL+xKPAFhKUOBQwSyU+AzFXEvDFf3sCCnrxh8O3Ujwh+fXZvjoZ+udTAERqR5IgKEBRAAAAAElFTkSuQmCC // ==/UserScript== // Have a nice day. - A Pseudonymous Coder @@ -1092,7 +1093,7 @@ function injectMe() { // This is needed to make this script work in Chrome. scrollDiv.appendChild(helpPage); bbb.el.menu.helpPage = helpPage; - helpPage.bbbTextSection('Thumbnail Matching Rules', 'For creating thumbnail matching rules, please consult the following examples:

Wildcards can be used with any of the above methods:

Multiple match rules can be applied by using commas:

The following metatags are supported:

The id, score, favcount, width, and height metatags can also use number ranges for matching:'); + helpPage.bbbTextSection('Thumbnail Matching Rules', 'For creating thumbnail matching rules, please consult the following examples:

Wildcards can be used with any of the above methods:

Multiple match rules can be applied by using commas:

The following metatags are supported:

The id, score, favcount, width, and height metatags can also use number ranges for matching:'); helpPage.bbbTextSection('Questions, Suggestions, or Bugs?', 'If you have any questions, please use the UserScripts forums located here. If you\'d like to report a bug or make a suggestion, please create an issue on GitHub here.'); helpPage.bbbTocSection(); @@ -2543,24 +2544,28 @@ function injectMe() { // This is needed to make this script work in Chrome. var thumbClass = ""; if (post.is_deleted) { - flags = "deleted"; + flags += " deleted"; thumbClass += " post-status-deleted"; } - if (post.is_flagged) { - flags = "flagged"; - thumbClass += " post-status-flagged"; - } if (post.is_pending) { - flags = "pending"; + flags += " pending"; thumbClass += " post-status-pending"; } + if (post.is_banned) + flags += " banned"; + if (flags === "") + flags += " active"; + if (post.is_flagged) { + flags += " flagged"; + thumbClass += " post-status-flagged"; + } if (post.has_children) thumbClass += " post-status-has-children"; if (post.parent_id) thumbClass += " post-status-has-parent"; post.parent = (post.parent_id ? post.parent_id : ""); - post.flags = flags; + post.flags = flags.bbbSpaceClean(); post.thumb_class = thumbClass; return post; @@ -2902,8 +2907,8 @@ function injectMe() { // This is needed to make this script work in Chrome. var id = post.getAttribute("data-id"); var width = post.getAttribute("data-width"); var height = post.getAttribute("data-height"); - var flags = post.getAttribute("data-flags") || "active"; - var status = (flags === "flagged" ? " status:flagged status:active" : " status:" + flags); + var flags = post.getAttribute("data-flags"); + var status = " status:" + flags.replace(/\s/g, " status:"); var postInfo = { tags: (tags + rating + status + user + pools).bbbSpacePad(), score: Number(score), From fd8eb7bd869543cf70b9af65d658b3272a63260a Mon Sep 17 00:00:00 2001 From: Moebius-Strip Date: Sun, 16 Feb 2014 20:47:11 -0500 Subject: [PATCH 03/10] Hiddent comment fixes + Tag list scrollbars * Fixed the problems with missing info on hidden images in the comments section. * Added an option for tweaking the tag lists on individual posts with a limited height and scrollbars. The scrollbars are a style I've been using in stylish for a long time and basically work the same way as the scrolling "favorited by" list that used to be in the script. It'll allow the user to easily limit the length of the tag lists so that they don't move all the sidebar options below them way off the screen. I hope I didn't word the description for it too oddly... --- better-better-booru.user.js | 45 +++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/better-better-booru.user.js b/better-better-booru.user.js index 8c3c019..c5724c9 100644 --- a/better-better-booru.user.js +++ b/better-better-booru.user.js @@ -69,12 +69,13 @@ function injectMe() { // This is needed to make this script work in Chrome. track_new: new Option("checkbox", false, "Track New Posts", "Add a menu option titled \"New\" to the posts section submenu (between \"Listing\" and \"Upload\") that links to a customized search focused on keeping track of new posts.

Note
While browsing the new posts, the current page of images is also tracked. If the new post listing is left, clicking the \"New\" link later on will attempt to pull up the images where browsing was left off at.

Tip
If you would like to bookmark the new post listing, drag and drop the link to your bookmarks or right click it and bookmark/copy the location from the context menu."), status_borders: borderSet(["deleted", true, "#000000", "solid", "post-status-deleted"], ["flagged", true, "#FF0000", "solid", "post-status-flagged"], ["pending", true, "#0000FF", "solid", "post-status-pending"], ["child", true, "#CCCC00", "solid", "post-status-has-parent"], ["parent", true, "#00FF00", "solid", "post-status-has-children"]), tag_borders: borderSet(["loli", true, "#FFC0CB", "solid"], ["shota", true, "#66CCFF", "solid"], ["toddlercon", true, "#9370DB", "solid"]), + tag_scrollbars: new Option("dropdown", false, "Tag Scrollbars", "Limit the length of the sidebar tag list(s) for individual posts by restricting them to a set height in pixels. For lists that exceed the set height, a scrollbar will be added to allow the rest of the list to be viewed.

Note
When using \"Remove Tag Headers\", this option will limit the overall length of the combined list.", {txtOptions:["Disabled:false"], numList:[50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,1000]}), track_new_data: {viewed:0, viewing:1} }, sections: { // Setting sections and ordering. browse: new Section("general", ["show_loli", "show_shota", "show_toddlercon", "show_deleted", "thumbnail_count"], "Image Browsing"), layout: new Section("general", ["hide_sign_up_notice", "hide_upgrade_notice", "hide_tos_notice", "hide_original_notice", "hide_advertisements", "hide_ban_notice"], "Layout"), - sidebar: new Section("general", ["search_add", "remove_tag_headers", "autohide_sidebar"], "Tag Sidebar"), + sidebar: new Section("general", ["search_add", "remove_tag_headers", "tag_scrollbars", "autohide_sidebar"], "Tag Sidebar"), image_control: new Section("general", ["alternate_image_swap", "image_resize_mode", "image_drag_scroll", "autoscroll_image"], "Image Control"), logged_out: new Section("general", ["image_resize", "load_sample_first", "script_blacklisted_tags"], "Logged Out Settings"), misc: new Section("general", ["direct_downloads", "track_new", "clean_links", "arrow_nav", "post_tag_titles"], "Misc."), @@ -135,6 +136,7 @@ function injectMe() { // This is needed to make this script work in Chrome. var image_drag_scroll = bbb.user.image_drag_scroll; var load_sample_first = bbb.user.load_sample_first; var remove_tag_headers = bbb.user.remove_tag_headers; + var tag_scrollbars = bbb.user.tag_scrollbars; var post_tag_titles = bbb.user.post_tag_titles; var autoscroll_image = bbb.user.autoscroll_image; @@ -144,6 +146,9 @@ function injectMe() { // This is needed to make this script work in Chrome. var track_new_data = bbb.user.track_new_data; var script_blacklisted_tags = bbb.user.script_blacklisted_tags; + // Other data + var bbbHiddenImg = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJYAAACWCAIAAACzY+a1AAAefElEQVR4Xu2Yva8md3XHEe8giBAgUYJEbAAhWiT+AzoiUWIUmgAIUYQWaFLaDQVdEBWpQKKhjF2RIkhOAUayQ7z3rtd42fUujpcY7I1JZu73PJ/PzByN5pm9duJFz3lmfr/z8j3vc62FN/3DfU4nGlf4P/ctnegvcIWnFZ7otMITnVZ4otMKTyv885+Hd7zrzDFIYQMJEnM4Iow0leNdppzgwZExl8Yklw3IBNHoG1EmrCUbnRMPz7xgTVTpVXSkETPN6tpCcoiz04II0FMUWFc4COPjVQiTOrRC0WymZpaSxSdutBYZh3gQA3DiBgEVOpm4GC4/sNRheYW0kCAqkK3Lx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S0jeOOQNjtyqnU+vuJNW/ayYsiO3UcG2MqG2QitPuV7DnYuZRF3vAThSsAAsLt6q8jhWe8pVeO0B+B5wRrGqKkZYBYuJiJaiS2KV5EjEFRhPauBk5oHGSYN1lt7MEcM7RWsnRwFqhdVsiP456JisXOylmzrr/FQ56kaLjDopa09juKnzQ3C1jmsZrQ9hRClE0ql4DjsKDJszakOSJ5BY2Dx8rZTICu9TOhErPNFphSc6rfBEpxWeVnii0wpPdFrhiU4rPK3wRKcV3q90WuGJTis80WmFpxXe53Si/wVkMsbi+PBDegAAAABJRU5ErkJggg=="; + // List of valid URL's to parse for. Feel free to suggest more! var valid_urls = [ "http://danbooru.donmai.us/", @@ -299,10 +304,8 @@ function injectMe() { // This is needed to make this script work in Chrome. function modifyPage(mode) { // Let other functions that don't require the API run. (Alternative to searchJSON) - if (mode === "post") { - if (!needPostAPI()) - fetchInfo(); - } + if (mode === "post") + fetchInfo(); else if (mode === "search" || mode === "notes") { if (allowUserLimit()) { var url = gUrl; @@ -423,9 +426,17 @@ function injectMe() { // This is needed to make this script work in Chrome. var comments = commentSection.getElementsByClassName("comment"); var numComments = comments.length; var toShow = 6; // Number of comments to display. + var twitterImg = xmlhttp.responseText.match(/\/ssd\/data\/preview\/(\w+)\.jpg/); + var previewImg = post.getElementsByTagName("img")[0]; target = post.getElementsByClassName("comments-for-post")[0]; newContent = document.createDocumentFragment(); + // Fix the image. + if (twitterImg && previewImg) { + previewImg.src = twitterImg[0]; + previewImg.alt = twitterImg[1]; + } + // Fix the comments. if (numComments > toShow) { for (var i = 0, toHide = numComments - toShow; i < toHide; i++) @@ -531,7 +542,6 @@ function injectMe() { // This is needed to make this script work in Chrome. var post = formatJSON(posts[i]); var outId = ""; var thumb = ""; - var hiddenImg; // Don't display loli/shota/toddlercon/deleted if the user has opted so and skip to the next image. if ((!show_loli && /\bloli\b/.test(post.tag_string)) || (!show_shota && /\bshota\b/.test(post.tag_string)) || (!show_toddlercon && /\btoddlercon\b/.test(post.tag_string)) || (!show_deleted && post.is_deleted)) { @@ -543,13 +553,9 @@ function injectMe() { // This is needed to make this script work in Chrome. continue; } - // Provide hidden images with a placeholder. (Hotfix) - if (!post.preview_file_url) { - if (!hiddenImg) - hiddenImg = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJYAAACWCAIAAACzY+a1AAAefElEQVR4Xu2Yva8md3XHEe8giBAgUYJEbAAhWiT+AzoiUWIUmgAIUYQWaFLaDQVdEBWpQKKhjF2RIkhOAUayQ7z3rtd42fUujpcY7I1JZu73PJ/PzByN5pm9duJFz3lmfr/z8j3vc62FN/3DfU4nGlf4P/ctnegvcIWnFZ7otMITnVZ4otMKTyv885+Hd7zrzDFIYQMJEnM4Iow0leNdppzgwZExl8Yklw3IBNHoG1EmrCUbnRMPz7xgTVTpVXSkETPN6tpCcoiz04II0FMUWFc4COPjVQiTOrRC0WymZpaSxSdutBYZh3gQA3DiBgEVOpm4GC4/sNRheYW0kCAqkK3LxB0wcfhGCBJ/W7WSaUF4ayOQceffqcU5ywJMV8hyGJqdI8ORA73xl2YqwAQKUsY7Sg+nSQxDzsGWoNkvRDFIL7iVykQbymoYLoy+ers4FTL0Ha1SdUs26LDCVyNeggyxDXydkwkSBnvpci5fcld7I3lp0tpX+Oqr0b86HtyjEk3Zw74aTrTj0rtuoH2qc1H3BIyXSr0TkBJbRuPTMoZwDZkHH+xkJYVT4aDATglgq0xa7/BMNnjjRYaZz88VDpZkKYocSEl5c4GOPXIlqPwaZ3NPMPWEDiBm4SzabRSKJHEzW/Ew0+iS0f1cHKERzBSVhZu7fcS0GoCahGKQpgoMRZSaGIBY1bXCaX8mso08mpH4yCIB04NQEAOAny88YO3FG1GjMjCsvRDJcH6CC6z6VNGyIHvPjE67EXH16N4oOKJahGSF0n/DrWjUa1Ll2fHq12MeDdi0bytU7Uy1CXcUCK8pGZgVRvAdnxwDXUBHtq2oTHmDL90BiZR4OsWlbVeIScNHJkcLE5XVVwE4ClnExqTCks2s/0iauBM1M0N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Vm9QCS0mBetmqjpZkZ84+gaofVhgkkYeTKXM4ztgxWluwvDZuJdGRhdNVVCXcsoYSFQU5qQwXo9DHsizUZXPfYcCR0wsjB1eCuCJTOh6w9scw2TGfsGNG6QqJC4sANWNXem44rwJcSNeuO3Ww/GtL28NxQ0rH1rwbx1/hlVHwGO8rIzue46shmKjCSyrkdSVM2PBJhQ1r9MbJAwWuzjgCJGMaBon0SQdZTosLksSyYkQiarX56UQFaWQJAOJdNldYtgs6zAIhGapfyzGaC08YNoF/VwQo5xyMdaVNhTKDiZAjFzYKoaEcelVUv1Mg/CxVSDJExme+CRi/PX1LR9ywheqfM5T+RJWxVjjpP7DwKJhDFe8uMOUlCI5Gm26mWgFHDE5yMTRTWIIRgFMlu6MSiHHrbXcMAy7+7JUN4W/vHl1OQKJrjSxPaKkyUpMBDiu8FJ3tgAK+T+lsD/Z1TK7oCp/O+3Ssw/308AiPRYSCCjmtYVQmSql0b4qVOL0StZY8nkhPB6ljS0jeOOQNjtyqnU+vuJNW/ayYsiO3UcG2MqG2QitPuV7DnYuZRF3vAThSsAAsLt6q8jhWe8pVeO0B+B5wRrGqKkZYBYuJiJaiS2KV5EjEFRhPauBk5oHGSYN1lt7MEcM7RWsnRwFqhdVsiP456JisXOylmzrr/FQ56kaLjDopa09juKnzQ3C1jmsZrQ9hRClE0ql4DjsKDJszakOSJ5BY2Dx8rZTICu9TOhErPNFphSc6rfBEpxWeVnii0wpPdFrhiU4rPK3wRKcV3q90WuGJTis80WmFpxXe53Si/wVkMsbi+PBDegAAAABJRU5ErkJggg=="; - - post.preview_file_url = hiddenImg; - } + // Provide hidden images with a placeholder. + if (!post.preview_file_url) + post.preview_file_url = bbbHiddenImg; // eek, huge line. thumb = '
' + post.tag_string + '
'; @@ -656,6 +662,7 @@ function injectMe() { // This is needed to make this script work in Chrome. resizeNotice.parentNode.removeChild(resizeNotice); var bbbResizeNotice = document.createElement("div"); + bbbResizeNotice.id = "image-resize-notice"; bbbResizeNotice.className = "ui-corner-all ui-state-highlight notice notice-resized"; bbbResizeNotice.style.position = "relative"; bbbResizeNotice.style.display = "none"; @@ -915,6 +922,13 @@ function injectMe() { // This is needed to make this script work in Chrome. var limit = (thumbnail_count ? "&limit=" + thumbnail_count : ""); var tag; + // Temporary information for hidden images. + if (!post.preview_file_url) + post.preview_file_url = bbbHiddenImg; + + if (!post.md5) + post.md5 = ""; + for (var j = 0, gtl = generalTags.length; j < gtl; j++) { tag = generalTags[j]; tagLinks = tagLinks.replace(tag.bbbSpacePad(), ' ' + tag.replace(/_/g, " ") + ' '); @@ -945,7 +959,7 @@ function injectMe() { // This is needed to make this script work in Chrome. else // Insert new post before the post that should follow it. existingPost.parentNode.insertBefore(childSpan.firstChild, existingPost); - // Get the comments. + // Get the comments and image info. fetchPages("/posts/" + post.id, "comments", {post: existingPosts[eci], post_id: post.id}); } @@ -2723,6 +2737,9 @@ function injectMe() { // This is needed to make this script work in Chrome. '.ui-autocomplete {z-index: 2002 !important;}'; } + if (tag_scrollbars) + styles += "#tag-list ul {max-height: " + tag_scrollbars + "px !important; overflow-y: auto !important; font-size: 87.5% !important;}"; + if (hide_advertisements) { styles += '#content.with-ads {margin-right: 0em !important;}' + 'img[alt="Advertisement"] {display: none !important;}' + From 583ef13dbeab90001795f587c69b19b115d9f357 Mon Sep 17 00:00:00 2001 From: Moebius-Strip Date: Mon, 17 Feb 2014 02:09:44 -0500 Subject: [PATCH 04/10] Cleanup For the average user that just wants access to the occasional hidden image, this is pretty much a good alternative. For the user that outright searches for the hidden tags, the alternative isn't that great. What I've observed: 1) Hidden images get their information removed only if they're at the start of the results. 2) If you have a hidden image anywhere after a regular image in the results, it's information is not removed. 3) Banned and deleted posts do not count as actual hidden images and retain all their info. In short, if you search for the hidden tags, every post will have it's information removed. If you're just doing an average search, any consecutive hidden images at the start of the results will have their info removed while all other hidden images that come after a regular image will display properly. The errors (Failbooru) were making things quite a pain to test... Considering other approaches, but this might be good as a starting release. --- better-better-booru.user.js | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/better-better-booru.user.js b/better-better-booru.user.js index c5724c9..994c475 100644 --- a/better-better-booru.user.js +++ b/better-better-booru.user.js @@ -8,7 +8,6 @@ // @match http://*.donmai.us/* // @match https://*.donmai.us/* // @match http://donmai.us/* -// @exclude http://trac.donmai.us/* // @run-at document-end // @grant none // @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAAAAABWESUoAAAA9klEQVQ4y2NgGBgQu/Dau1/Pt/rhVPAfCkpwKXhUZ8Al2vT//yu89vDjV8AkP/P//zY0K//+eHVmoi5YyB7I/VDGiKYADP60wRT8P6aKTcH//0lgQcHS//+PYFdwFu7Ib8gKGBgYOQ22glhfGO7mqbEpzv///xyqAiAQAbGewIz8aoehQArEWsyQsu7O549XJiowoCpg4rM9CGS8V8UZ9GBwy5wBr4K/teL4Ffz//8mHgIL/v82wKgA6kkXE+zKIuRaHAhDQATFf4lHABmL+xKPAFhKUOBQwSyU+AzFXEvDFf3sCCnrxh8O3Ujwh+fXZvjoZ+udTAERqR5IgKEBRAAAAAElFTkSuQmCC @@ -325,28 +324,24 @@ function injectMe() { // This is needed to make this script work in Chrome. var imgContainer = document.getElementById("image-container"); var img = document.getElementById("image"); var object = imgContainer.getElementsByTagName("object")[0]; - var childNotice = document.getElementsByClassName("notice-child"); var resizeNotice = document.getElementById("image-resize-notice"); var postId = imgContainer.getAttribute("data-id"); - var infoSection = document.getElementById("score-for-post-" + postId).parentNode.parentNode; + var infoLink = document.evaluate('//aside[@id="sidebar"]/section/ul/li/a[starts-with(@href, "/data/")]', document, null, 9, null).singleNodeValue; + var twitterInfo = fetchMeta("twitter:image:src"); + var infoValues; var md5 = ""; var ext = ""; - var infoLink = document.evaluate('//aside[@id="sidebar"]/section/ul/li/a[starts-with(@href, "/data/")]', document, null, 9, null).singleNodeValue; - var twitterInfo = fetchMeta("twitter:image:src"); + if (infoLink) + infoValues = /data\/(\w+?)\.(\w+?)$/.exec(infoLink.href); + else if (twitterInfo) + infoValues = /(?:data\/sample\/sample-|data\/)(\w+?)\.(\w+?)$/.exec(twitterInfo); - if (infoLink) { - var infoHrefValues = (infoLink ? /data\/(.+?)\.(.+?)$/.exec(infoLink.href) : null); - md5 = infoHrefValues[1]; - ext = infoHrefValues[2]; - } - else if (twitterInfo) { - var twitterInfoValues = (twitterInfo ? /(?:data\/sample\/sample-|data\/)(.+?)\.(.+?)$/.exec(twitterInfo) : null); - md5 = twitterInfoValues[1]; - ext = twitterInfoValues[2]; + if (infoValues) { + md5 = infoValues[1]; + ext = infoValues[2]; } - - if (!md5) { // Irregular hidden files do not provide enough info to be found (bmp, rar, zip, etc). + else { // Irregular hidden files do not provide enough info to be found (bmp, rar, zip, etc). danbNotice("Better Better Booru: Due to a lack of provided information, this post cannot be viewed.", "error"); bbbStatus("error"); return; @@ -358,11 +353,11 @@ function injectMe() { // This is needed to make this script work in Chrome. if (hasLarge && !infoLink) { // Test for the original image file extension if it is unknown. if (resizeNotice) - ext = /(?:data\/sample\/sample-|data\/).+?\.(\w+?)$/.exec(resizeNotice.getElementsByTagName("a")[0].href)[1]; + ext = /(?:data\/sample\/sample-|data\/)\w+?\.(\w+?)$/.exec(resizeNotice.getElementsByTagName("a")[0].href)[1]; else { var testExt = ["jpg", "png", "gif", "jpeg"]; - for (var i = 0, numExt = testExt.length; i < numExt; i++) { + for (var i = 0, tel = testExt.length; i < tel; i++) { if (isThere("/data/" + md5 + "." + testExt[i])) { ext = testExt[i]; break; From ec791fa8781cebdb5c3040fc134f3766969435e8 Mon Sep 17 00:00:00 2001 From: Moebius-Strip Date: Fri, 21 Feb 2014 01:33:17 -0500 Subject: [PATCH 05/10] Fixed thumbnails + Thumbnail cache * Updated to search for thumbnail info in order to fix broken/hidden thumbnails. * Added a cache for storing the md5/filename info for thumbnails in order to reduce search and load times. --- better-better-booru.user.js | 196 ++++++++++++++++++++++++++++++------ 1 file changed, 164 insertions(+), 32 deletions(-) diff --git a/better-better-booru.user.js b/better-better-booru.user.js index 994c475..450b962 100644 --- a/better-better-booru.user.js +++ b/better-better-booru.user.js @@ -23,8 +23,15 @@ function injectMe() { // This is needed to make this script work in Chrome. /* Global Variables */ var bbb = { // Container for script info. + cache: { + current: { + history: [], + names: {} + }, + stored: {} + }, el: { // Script elements. - menu:{} // Menu elements. + menu: {} // Menu elements. }, img: { // Post content info. resized: "none", @@ -68,11 +75,12 @@ function injectMe() { // This is needed to make this script work in Chrome. track_new: new Option("checkbox", false, "Track New Posts", "Add a menu option titled \"New\" to the posts section submenu (between \"Listing\" and \"Upload\") that links to a customized search focused on keeping track of new posts.

Note
While browsing the new posts, the current page of images is also tracked. If the new post listing is left, clicking the \"New\" link later on will attempt to pull up the images where browsing was left off at.

Tip
If you would like to bookmark the new post listing, drag and drop the link to your bookmarks or right click it and bookmark/copy the location from the context menu."), status_borders: borderSet(["deleted", true, "#000000", "solid", "post-status-deleted"], ["flagged", true, "#FF0000", "solid", "post-status-flagged"], ["pending", true, "#0000FF", "solid", "post-status-pending"], ["child", true, "#CCCC00", "solid", "post-status-has-parent"], ["parent", true, "#00FF00", "solid", "post-status-has-children"]), tag_borders: borderSet(["loli", true, "#FFC0CB", "solid"], ["shota", true, "#66CCFF", "solid"], ["toddlercon", true, "#9370DB", "solid"]), - tag_scrollbars: new Option("dropdown", false, "Tag Scrollbars", "Limit the length of the sidebar tag list(s) for individual posts by restricting them to a set height in pixels. For lists that exceed the set height, a scrollbar will be added to allow the rest of the list to be viewed.

Note
When using \"Remove Tag Headers\", this option will limit the overall length of the combined list.", {txtOptions:["Disabled:false"], numList:[50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,1000]}), + tag_scrollbars: new Option("dropdown", false, "Tag Scrollbars", "Limit the length of the sidebar tag lists for individual posts by restricting them to a set height in pixels. For lists that exceed the set height, a scrollbar will be added to allow the rest of the list to be viewed.

Note
When using \"Remove Tag Headers\", this option will limit the overall length of the combined list.", {txtOptions:["Disabled:0"], numList:[50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,1000,1050,1100,1150,1200,1250,1300,1350,1400,1450,1500]}), + thumb_cache_limit: new Option("dropdown", 5000, "Thumbnail Info Cache Limit", "Limit the number of thumbnail information entries cached in the browser.

Note
No actual thumbnails are cached. Only information used to speed up the display of hidden thumbnails is stored. Every 500 entries is approximately equal to 51.2 kilobytes of space. The default value of 5000 is about 0.5 megabytes (512 kilobytes) of space.", {txtOptions:["Disabled:0"], numList:[500,1000,1500,2000,2500,3000,3500,4000,4500,5000,5500,6000,6500,7000,7500,8000,8500,9000,9500,10000,10500,11000,11500,12000,12500,13000,13500,14000,14500,15000,15500,16000,16500,17000,17500,18000,18500,19000,19500,20000,20500,21000,21500,22000,22500,23000,23500,24000,24500,25000,25500,26000,26500,27000,27500,28000,28500,29000,29500,30000]}), track_new_data: {viewed:0, viewing:1} }, sections: { // Setting sections and ordering. - browse: new Section("general", ["show_loli", "show_shota", "show_toddlercon", "show_deleted", "thumbnail_count"], "Image Browsing"), + browse: new Section("general", ["show_loli", "show_shota", "show_toddlercon", "show_deleted", "thumbnail_count", "thumb_cache_limit"], "Image Browsing"), layout: new Section("general", ["hide_sign_up_notice", "hide_upgrade_notice", "hide_tos_notice", "hide_original_notice", "hide_advertisements", "hide_ban_notice"], "Layout"), sidebar: new Section("general", ["search_add", "remove_tag_headers", "tag_scrollbars", "autohide_sidebar"], "Tag Sidebar"), image_control: new Section("general", ["alternate_image_swap", "image_resize_mode", "image_drag_scroll", "autoscroll_image"], "Image Control"), @@ -127,6 +135,7 @@ function injectMe() { // This is needed to make this script work in Chrome. var search_add = bbb.user.search_add; var thumbnail_count = bbb.user.thumbnail_count; var thumbnail_count_default = 20; // Number of thumbnails BBB should expect Danbooru to return by default. + var thumb_cache_limit = bbb.user.thumb_cache_limit; // Post var alternate_image_swap = bbb.user.alternate_image_swap; @@ -325,17 +334,22 @@ function injectMe() { // This is needed to make this script work in Chrome. var img = document.getElementById("image"); var object = imgContainer.getElementsByTagName("object")[0]; var resizeNotice = document.getElementById("image-resize-notice"); - var postId = imgContainer.getAttribute("data-id"); - var infoLink = document.evaluate('//aside[@id="sidebar"]/section/ul/li/a[starts-with(@href, "/data/")]', document, null, 9, null).singleNodeValue; + var directLink = document.evaluate('//aside[@id="sidebar"]/section/ul/li/a[starts-with(@href, "/data/")]|//a[@id="image-resize-link"]', document, null, 9, null).singleNodeValue; var twitterInfo = fetchMeta("twitter:image:src"); + var headInfo = document.getElementsByTagName("head")[0].innerHTML; + var imgHeight = Number(imgContainer.getAttribute("data-height")); + var imgWidth = Number(imgContainer.getAttribute("data-width")); + var hasLarge = (imgWidth > 850 && ext !== "swf" ? true : false); var infoValues; var md5 = ""; var ext = ""; - if (infoLink) - infoValues = /data\/(\w+?)\.(\w+?)$/.exec(infoLink.href); + if (directLink) + infoValues = /data\/(\w+)\.(\w+)/.exec(directLink.href); else if (twitterInfo) - infoValues = /(?:data\/sample\/sample-|data\/)(\w+?)\.(\w+?)$/.exec(twitterInfo); + infoValues = (twitterInfo.indexOf("sample") > -1 ? /data\/sample\/sample-(\w+)\.\w/.exec(twitterInfo) : /data\/(\w+)\.(\w+)/.exec(twitterInfo)); + else if (headInfo) + infoValues = /ssd\/data\/preview\/(\w+?)\.\w/.exec(headInfo); if (infoValues) { md5 = infoValues[1]; @@ -347,27 +361,19 @@ function injectMe() { // This is needed to make this script work in Chrome. return; } - var imgHeight = Number(imgContainer.getAttribute("data-height")); - var imgWidth = Number(imgContainer.getAttribute("data-width")); - var hasLarge = (imgWidth > 850 && ext !== "swf" ? true : false); + if (!ext && imgWidth) { // Test for the original image file extension if it is unknown. + var testExt = ["jpg", "png", "gif", "jpeg"]; - if (hasLarge && !infoLink) { // Test for the original image file extension if it is unknown. - if (resizeNotice) - ext = /(?:data\/sample\/sample-|data\/)\w+?\.(\w+?)$/.exec(resizeNotice.getElementsByTagName("a")[0].href)[1]; - else { - var testExt = ["jpg", "png", "gif", "jpeg"]; - - for (var i = 0, tel = testExt.length; i < tel; i++) { - if (isThere("/data/" + md5 + "." + testExt[i])) { - ext = testExt[i]; - break; - } + for (var i = 0, tel = testExt.length; i < tel; i++) { + if (isThere("/data/" + md5 + "." + testExt[i])) { + ext = testExt[i]; + break; } } } var imgInfo = { - id: Number(postId), + id: Number(imgContainer.getAttribute("data-id")), file_ext: ext, md5: md5, fav_count: Number(imgContainer.getAttribute("data-fav-count")), @@ -421,15 +427,15 @@ function injectMe() { // This is needed to make this script work in Chrome. var comments = commentSection.getElementsByClassName("comment"); var numComments = comments.length; var toShow = 6; // Number of comments to display. - var twitterImg = xmlhttp.responseText.match(/\/ssd\/data\/preview\/(\w+)\.jpg/); + var metaInfo = /\/ssd\/data\/preview\/(\w+)\.jpg/.exec(xmlhttp.responseText); var previewImg = post.getElementsByTagName("img")[0]; target = post.getElementsByClassName("comments-for-post")[0]; newContent = document.createDocumentFragment(); // Fix the image. - if (twitterImg && previewImg) { - previewImg.src = twitterImg[0]; - previewImg.alt = twitterImg[1]; + if (metaInfo && previewImg) { + previewImg.src = metaInfo[0]; + previewImg.alt = metaInfo[1]; } // Fix the comments. @@ -473,6 +479,33 @@ function injectMe() { // This is needed to make this script work in Chrome. // Update status message. bbbStatus("loaded"); } + else if (mode === "hidden") { // Fetch the hidden image information from a post for thumbnails. + var hiddenImgs = optArg; + var postId = hiddenImgs.shift(); + var metaInfo = /\/ssd\/data\/preview\/(\w+)\.jpg|\/images\/(download-preview).png/.exec(xmlhttp.responseText); + + if (metaInfo) { // Update the thumbnail with the correct information and continue to the next. + var filename = metaInfo[1] || metaInfo[2]; + var bcc = bbb.cache.current; + var bcs = bbb.cache.stored; + + document.getElementById("bbb-img-" + postId).src = metaInfo[0]; + bcc.history.push(postId); + bcc.names[postId] = filename; + + if (hiddenImgs.length) + fetchPages("/posts/" + hiddenImgs[0], "hidden", hiddenImgs); + else { + updateThumbCache(); + bbbStatus("loaded"); + } + } + else { // The image information couldn't be found. + updateThumbCache(); + danbNotice("Better Better Booru: Error retrieving thumbnail information.", "error"); + bbbStatus("error"); + } + } } else if (xmlhttp.status !== 0) { danbNotice("Better Better Booru: Error retrieving information. (Code: " + xmlhttp.status + " " + xmlhttp.statusText + ")", "error"); @@ -499,6 +532,7 @@ function injectMe() { // This is needed to make this script work in Chrome. var posts = xml; var search = ""; var where; + var hiddenImgs = []; var paginator = document.getElementsByClassName("paginator")[0]; // If no posts, do nothing. @@ -548,12 +582,27 @@ function injectMe() { // This is needed to make this script work in Chrome. continue; } - // Provide hidden images with a placeholder. - if (!post.preview_file_url) - post.preview_file_url = bbbHiddenImg; + // Alter hidden images. + if (!post.preview_file_url) { + if (!bbb.cache.stored.history) + loadThumbCache(); + + var cacheName = bbb.cache.stored.names[post.id]; + + if (cacheName) { // Load the thumbnail info from the cache. + if (cacheName === "download-preview") + post.preview_file_url = "/images/download-preview.png"; + else + post.preview_file_url = "/ssd/data/preview/" + cacheName + ".jpg"; + } + else { // Provide the hidden image with a placeholder and queue it for fixing. + post.preview_file_url = bbbHiddenImg; + hiddenImgs.push(post.id); + } + } // eek, huge line. - thumb = '
' + post.tag_string + '
'; + thumb = '
' + post.tag_string + '
'; if (direct_downloads) thumb += 'Direct Download'; @@ -604,6 +653,13 @@ function injectMe() { // This is needed to make this script work in Chrome. // Blacklist. blacklistInit(); + // Fix hidden thumbnails. + if (hiddenImgs.length) { + window.addEventListener("beforeunload", updateThumbCache); + fetchPages("/posts/" + hiddenImgs[0], "hidden", hiddenImgs); + bbbStatus("hidden"); + } + // Update status message. bbbStatus("loaded"); } @@ -2009,10 +2065,13 @@ function injectMe() { // This is needed to make this script work in Chrome. } function saveSettings() { - // Save the user settings to localStorage after making any neccessary checks/adjustments. + // Save the user settings to localStorage after making any necessary checks/adjustments. if (!bbb.user.track_new && bbb.user.track_new_data.viewed) // Reset new post tracking if it's disabled. bbb.user.track_new_data = bbb.options.track_new_data.def; + if (thumb_cache_limit !== bbb.user.thumb_cache_limit) // Trim down the thumb cache as necessary if the limit has changed. + adjustThumbCache(); + localStorage.bbb_settings = JSON.stringify(bbb.user); } @@ -2187,6 +2246,74 @@ function injectMe() { // This is needed to make this script work in Chrome. } } + function loadThumbCache() { + // Initialize or load up the thumbnail cache. + if (typeof(localStorage.bbb_thumb_cache) !== "undefined") + bbb.cache.stored = JSON.parse(localStorage.bbb_thumb_cache); + else { + bbb.cache.stored = {history: [], names: {}}; + localStorage.bbb_thumb_cache = JSON.stringify(bbb.cache.stored); + } + } + + function updateThumbCache() { + // Add the current new thumbnail info to the saved thumbnail information. + if (!bbb.cache.current.history.length || !thumb_cache_limit) + return; + + bbb.cache.stored = JSON.parse(localStorage.bbb_thumb_cache); + + var bcc = bbb.cache.current; + var bcs = bbb.cache.stored; + + // Make sure we don't have duplicates in the new info. + for (var i = 0, bhl = bcc.history.length; i < bhl; i++) { + if (bcs.names[bcc.history[i]]) { + delete bcc.names[bcc.history[i]]; + bcc.history.splice(i, 1); + bhl--; + i--; + } + } + + // Add the new thumbnail info in. + for (var i in bcc.names) { + if (bcc.names.hasOwnProperty(i)) { + bcs.names[i] = bcc.names[i]; + } + } + + bcs.history = bcs.history.concat(bcc.history); + + // Prune the cache if it's larger than the user limit. + if (bcs.history.length > thumb_cache_limit) { + var removedIDs = bcs.history.splice(0, bcs.history.length - thumb_cache_limit); + + for (var i = 0, rtl = removedIDs.length; i < rtl; i++) + delete bcs.names[removedIDs[i]]; + } + + localStorage.bbb_thumb_cache = JSON.stringify(bcs); + bbb.cache.current = {history: [], names: {}}; + } + + function adjustThumbCache() { + // Prune the cache if it's larger than the user limit. + bbb.cache.stored = JSON.parse(localStorage.bbb_thumb_cache); + thumb_cache_limit = bbb.user.thumb_cache_limit; + + var bcs = bbb.cache.stored; + + if (bcs.history.length > thumb_cache_limit) { + var removedIDs = bcs.history.splice(0, bcs.history.length - thumb_cache_limit); + + for (var i = 0, rtl = removedIDs.length; i < rtl; i++) + delete bcs.names[removedIDs[i]]; + } + + localStorage.bbb_thumb_cache = JSON.stringify(bcs); + } + function limitFix() { // Add the limit variable to link URLs that are not thumbnails. var links = document.evaluate('//div[@id="page"]//a[starts-with(@href, "/posts?")]', document, null, 6, null); @@ -3213,6 +3340,11 @@ function injectMe() { // This is needed to make this script work in Chrome. status.innerHTML = "Loading comment info..."; bbb.statusCount++; } + else if (mode === "hidden") { // Status mode for fixing "Hidden" thumbnails. + status.style.display = "block"; + status.innerHTML = "Loading hidden thumbnails..."; + bbb.statusCount++; + } else if (mode === "loaded") { // Status mode for successful requests. Hides itself automatically. bbb.statusCount--; From 2834bc5dbbcd5019b2f238982019ebafde6bcca3 Mon Sep 17 00:00:00 2001 From: Moebius-Strip Date: Fri, 21 Feb 2014 01:44:45 -0500 Subject: [PATCH 06/10] Cleanup Wrong default value. --- better-better-booru.user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/better-better-booru.user.js b/better-better-booru.user.js index 450b962..299f7f9 100644 --- a/better-better-booru.user.js +++ b/better-better-booru.user.js @@ -75,7 +75,7 @@ function injectMe() { // This is needed to make this script work in Chrome. track_new: new Option("checkbox", false, "Track New Posts", "Add a menu option titled \"New\" to the posts section submenu (between \"Listing\" and \"Upload\") that links to a customized search focused on keeping track of new posts.

Note
While browsing the new posts, the current page of images is also tracked. If the new post listing is left, clicking the \"New\" link later on will attempt to pull up the images where browsing was left off at.

Tip
If you would like to bookmark the new post listing, drag and drop the link to your bookmarks or right click it and bookmark/copy the location from the context menu."), status_borders: borderSet(["deleted", true, "#000000", "solid", "post-status-deleted"], ["flagged", true, "#FF0000", "solid", "post-status-flagged"], ["pending", true, "#0000FF", "solid", "post-status-pending"], ["child", true, "#CCCC00", "solid", "post-status-has-parent"], ["parent", true, "#00FF00", "solid", "post-status-has-children"]), tag_borders: borderSet(["loli", true, "#FFC0CB", "solid"], ["shota", true, "#66CCFF", "solid"], ["toddlercon", true, "#9370DB", "solid"]), - tag_scrollbars: new Option("dropdown", false, "Tag Scrollbars", "Limit the length of the sidebar tag lists for individual posts by restricting them to a set height in pixels. For lists that exceed the set height, a scrollbar will be added to allow the rest of the list to be viewed.

Note
When using \"Remove Tag Headers\", this option will limit the overall length of the combined list.", {txtOptions:["Disabled:0"], numList:[50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,1000,1050,1100,1150,1200,1250,1300,1350,1400,1450,1500]}), + tag_scrollbars: new Option("dropdown", 0, "Tag Scrollbars", "Limit the length of the sidebar tag lists for individual posts by restricting them to a set height in pixels. For lists that exceed the set height, a scrollbar will be added to allow the rest of the list to be viewed.

Note
When using \"Remove Tag Headers\", this option will limit the overall length of the combined list.", {txtOptions:["Disabled:0"], numList:[50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,1000,1050,1100,1150,1200,1250,1300,1350,1400,1450,1500]}), thumb_cache_limit: new Option("dropdown", 5000, "Thumbnail Info Cache Limit", "Limit the number of thumbnail information entries cached in the browser.

Note
No actual thumbnails are cached. Only information used to speed up the display of hidden thumbnails is stored. Every 500 entries is approximately equal to 51.2 kilobytes of space. The default value of 5000 is about 0.5 megabytes (512 kilobytes) of space.", {txtOptions:["Disabled:0"], numList:[500,1000,1500,2000,2500,3000,3500,4000,4500,5000,5500,6000,6500,7000,7500,8000,8500,9000,9500,10000,10500,11000,11500,12000,12500,13000,13500,14000,14500,15000,15500,16000,16500,17000,17500,18000,18500,19000,19500,20000,20500,21000,21500,22000,22500,23000,23500,24000,24500,25000,25500,26000,26500,27000,27500,28000,28500,29000,29500,30000]}), track_new_data: {viewed:0, viewing:1} }, From 23d056a03d90f17288e6bf1af1edfb97f39644ea Mon Sep 17 00:00:00 2001 From: Moebius-Strip Date: Sat, 22 Feb 2014 21:31:50 -0500 Subject: [PATCH 07/10] DDL fixes + Cache updates * Updated the cache to store extensions as well. * Fixed direct downloads on hidden posts. * Cut down the cache limit options to every 1000. * Added a temporary special case for test version users when converting settings. --- better-better-booru.user.js | 176 +++++++++++++++++++++++++----------- 1 file changed, 121 insertions(+), 55 deletions(-) diff --git a/better-better-booru.user.js b/better-better-booru.user.js index 299f7f9..4a2ed25 100644 --- a/better-better-booru.user.js +++ b/better-better-booru.user.js @@ -75,8 +75,8 @@ function injectMe() { // This is needed to make this script work in Chrome. track_new: new Option("checkbox", false, "Track New Posts", "Add a menu option titled \"New\" to the posts section submenu (between \"Listing\" and \"Upload\") that links to a customized search focused on keeping track of new posts.

Note
While browsing the new posts, the current page of images is also tracked. If the new post listing is left, clicking the \"New\" link later on will attempt to pull up the images where browsing was left off at.

Tip
If you would like to bookmark the new post listing, drag and drop the link to your bookmarks or right click it and bookmark/copy the location from the context menu."), status_borders: borderSet(["deleted", true, "#000000", "solid", "post-status-deleted"], ["flagged", true, "#FF0000", "solid", "post-status-flagged"], ["pending", true, "#0000FF", "solid", "post-status-pending"], ["child", true, "#CCCC00", "solid", "post-status-has-parent"], ["parent", true, "#00FF00", "solid", "post-status-has-children"]), tag_borders: borderSet(["loli", true, "#FFC0CB", "solid"], ["shota", true, "#66CCFF", "solid"], ["toddlercon", true, "#9370DB", "solid"]), - tag_scrollbars: new Option("dropdown", 0, "Tag Scrollbars", "Limit the length of the sidebar tag lists for individual posts by restricting them to a set height in pixels. For lists that exceed the set height, a scrollbar will be added to allow the rest of the list to be viewed.

Note
When using \"Remove Tag Headers\", this option will limit the overall length of the combined list.", {txtOptions:["Disabled:0"], numList:[50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,1000,1050,1100,1150,1200,1250,1300,1350,1400,1450,1500]}), - thumb_cache_limit: new Option("dropdown", 5000, "Thumbnail Info Cache Limit", "Limit the number of thumbnail information entries cached in the browser.

Note
No actual thumbnails are cached. Only information used to speed up the display of hidden thumbnails is stored. Every 500 entries is approximately equal to 51.2 kilobytes of space. The default value of 5000 is about 0.5 megabytes (512 kilobytes) of space.", {txtOptions:["Disabled:0"], numList:[500,1000,1500,2000,2500,3000,3500,4000,4500,5000,5500,6000,6500,7000,7500,8000,8500,9000,9500,10000,10500,11000,11500,12000,12500,13000,13500,14000,14500,15000,15500,16000,16500,17000,17500,18000,18500,19000,19500,20000,20500,21000,21500,22000,22500,23000,23500,24000,24500,25000,25500,26000,26500,27000,27500,28000,28500,29000,29500,30000]}), + tag_scrollbars: new Option("dropdown", 0, "Tag List Scrollbars", "Limit the length of the sidebar tag lists for individual posts by restricting them to a set height in pixels. For lists that exceed the set height, a scrollbar will be added to allow the rest of the list to be viewed.

Note
When using \"Remove Tag Headers\", this option will limit the overall length of the combined list.", {txtOptions:["Disabled:0"], numList:[50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,1000,1050,1100,1150,1200,1250,1300,1350,1400,1450,1500]}), + thumb_cache_limit: new Option("dropdown", 5000, "Thumbnail Info Cache Limit", "Limit the number of thumbnail information entries cached in the browser.

Note
No actual thumbnails are cached. Only information used to speed up the display of hidden thumbnails is stored. Every 1000 entries is approximately equal to 102.4 kilobytes (0.1 megabytes) of space.", {txtOptions:["Disabled:0"], numList:[1000,2000,3000,4000,5000,6000,7000,8000,9000,10000,11000,12000,13000,14000,15000,16000,17000,18000,19000,20000,21000,22000,23000,24000,25000,26000,27000,28000,29000,30000]}), track_new_data: {viewed:0, viewing:1} }, sections: { // Setting sections and ordering. @@ -333,70 +333,70 @@ function injectMe() { // This is needed to make this script work in Chrome. var imgContainer = document.getElementById("image-container"); var img = document.getElementById("image"); var object = imgContainer.getElementsByTagName("object")[0]; - var resizeNotice = document.getElementById("image-resize-notice"); var directLink = document.evaluate('//aside[@id="sidebar"]/section/ul/li/a[starts-with(@href, "/data/")]|//a[@id="image-resize-link"]', document, null, 9, null).singleNodeValue; var twitterInfo = fetchMeta("twitter:image:src"); - var headInfo = document.getElementsByTagName("head")[0].innerHTML; + var previewInfo = document.evaluate('//meta[@property="og:image"]', document, null, 9, null).singleNodeValue; var imgHeight = Number(imgContainer.getAttribute("data-height")); var imgWidth = Number(imgContainer.getAttribute("data-width")); var hasLarge = (imgWidth > 850 && ext !== "swf" ? true : false); - var infoValues; var md5 = ""; var ext = ""; + var infoValues; + // Try to extract the file's name and extension. if (directLink) infoValues = /data\/(\w+)\.(\w+)/.exec(directLink.href); else if (twitterInfo) infoValues = (twitterInfo.indexOf("sample") > -1 ? /data\/sample\/sample-(\w+)\.\w/.exec(twitterInfo) : /data\/(\w+)\.(\w+)/.exec(twitterInfo)); - else if (headInfo) - infoValues = /ssd\/data\/preview\/(\w+?)\.\w/.exec(headInfo); + else if (previewInfo) + infoValues = /ssd\/data\/preview\/(\w+?)\.\w/.exec(previewInfo.content); if (infoValues) { md5 = infoValues[1]; ext = infoValues[2]; - } - else { // Irregular hidden files do not provide enough info to be found (bmp, rar, zip, etc). - danbNotice("Better Better Booru: Due to a lack of provided information, this post cannot be viewed.", "error"); - bbbStatus("error"); - return; - } - if (!ext && imgWidth) { // Test for the original image file extension if it is unknown. - var testExt = ["jpg", "png", "gif", "jpeg"]; + // Test for the original image file extension if it is unknown. + if (!ext && imgWidth) { + var testExt = ["jpg", "png", "gif", "jpeg"]; - for (var i = 0, tel = testExt.length; i < tel; i++) { - if (isThere("/data/" + md5 + "." + testExt[i])) { - ext = testExt[i]; - break; + for (var i = 0, tel = testExt.length; i < tel; i++) { + if (isThere("/data/" + md5 + "." + testExt[i])) { + ext = testExt[i]; + break; + } } } - } - var imgInfo = { - id: Number(imgContainer.getAttribute("data-id")), - file_ext: ext, - md5: md5, - fav_count: Number(imgContainer.getAttribute("data-fav-count")), - has_children: (imgContainer.getAttribute("data-has-children") === "true" ? true : false), - parent_id: (imgContainer.getAttribute("data-parent-id") ? Number(imgContainer.getAttribute("data-parent-id")) : null), - rating: imgContainer.getAttribute("data-rating"), - score: Number(imgContainer.getAttribute("data-score")), - tag_string: imgContainer.getAttribute("data-tags"), - pool_string: imgContainer.getAttribute("data-pools"), - uploader_name: imgContainer.getAttribute("data-uploader"), - is_deleted: (fetchMeta("post-is-deleted") === "false" ? false : true), - is_flagged: (fetchMeta("post-is-flagged") === "false" ? false : true), - is_pending: (!document.getElementById("pending-approval-notice") ? false : true), - image_height: (imgHeight ? imgHeight : null), - image_width: (imgWidth ? imgWidth : null), - has_large: hasLarge, - file_url: "/data/" + md5 + "." + ext, - large_file_url: "/data/sample/sample-" + md5 + ".jpg", - preview_file_url: (!imgHeight || ext === "swf" ? "/images/download-preview.png" : "/ssd/data/preview/" + md5 + ".jpg"), - exists: (img || object ? true : false) - }; + var imgInfo = { + id: Number(imgContainer.getAttribute("data-id")), + file_ext: ext, + md5: md5, + fav_count: Number(imgContainer.getAttribute("data-fav-count")), + has_children: (imgContainer.getAttribute("data-has-children") === "true" ? true : false), + parent_id: (imgContainer.getAttribute("data-parent-id") ? Number(imgContainer.getAttribute("data-parent-id")) : null), + rating: imgContainer.getAttribute("data-rating"), + score: Number(imgContainer.getAttribute("data-score")), + tag_string: imgContainer.getAttribute("data-tags"), + pool_string: imgContainer.getAttribute("data-pools"), + uploader_name: imgContainer.getAttribute("data-uploader"), + is_deleted: (fetchMeta("post-is-deleted") === "false" ? false : true), + is_flagged: (fetchMeta("post-is-flagged") === "false" ? false : true), + is_pending: (!document.getElementById("pending-approval-notice") ? false : true), + image_height: (imgHeight ? imgHeight : null), + image_width: (imgWidth ? imgWidth : null), + has_large: hasLarge, + file_url: "/data/" + md5 + "." + ext, + large_file_url: "/data/sample/sample-" + md5 + ".jpg", + preview_file_url: (!imgHeight || ext === "swf" ? "/images/download-preview.png" : "/ssd/data/preview/" + md5 + ".jpg"), + exists: (img || object ? true : false) + }; - delayMe(function(){parsePost(imgInfo);}); // Delay is needed to force the script to pause and allow Danbooru to do whatever. It essentially mimics the async nature of the API call. + delayMe(function(){parsePost(imgInfo);}); // Delay is needed to force the script to pause and allow Danbooru to do whatever. It essentially mimics the async nature of the API call. + } + else { // Irregular hidden files do not provide enough info to be found (bmp, rar, zip, etc). + danbNotice("Better Better Booru: Due to a lack of provided information, this post cannot be viewed.", "error"); + bbbStatus("error"); + } } function fetchPages(url, mode, optArg) { @@ -482,17 +482,64 @@ function injectMe() { // This is needed to make this script work in Chrome. else if (mode === "hidden") { // Fetch the hidden image information from a post for thumbnails. var hiddenImgs = optArg; var postId = hiddenImgs.shift(); - var metaInfo = /\/ssd\/data\/preview\/(\w+)\.jpg|\/images\/(download-preview).png/.exec(xmlhttp.responseText); + var directLink = document.evaluate('.//aside[@id="sidebar"]/section/ul/li/a[starts-with(@href, "/data/")]|.//a[@id="image-resize-link"]', childSpan, null, 9, null).singleNodeValue; + var twitterInfo = document.evaluate('.//meta[@name="twitter:image:src"]', childSpan, null, 9, null).singleNodeValue; + var previewInfo = document.evaluate('.//meta[@property="og:image"]', childSpan, null, 9, null).singleNodeValue; + var md5 = ""; + var ext = ""; + var infoValues; + + // Try to extract the file's name and extension. + if (directLink) + infoValues = /data\/(\w+)\.(\w+)/.exec(directLink.href); + else if (twitterInfo) + infoValues = (twitterInfo.content.indexOf("sample") > -1 ? /data\/sample\/sample-(\w+)\.\w/.exec(twitterInfo.content) : /data\/(\w+)\.(\w+)/.exec(twitterInfo.content)); + else if (previewInfo) + infoValues = (previewInfo.content.indexOf("download-preview.png") > -1 ? ["/images/download-preview.png", "download-preview", "png"] : /ssd\/data\/preview\/(\w+?)\.\w/.exec(previewInfo.content)); + + if (infoValues) { + md5 = infoValues[1]; + ext = infoValues[2]; + + // Test for the original image file extension if it is unknown. + if (!ext) { + var testExt = ["jpg", "png", "gif", "jpeg"]; + + for (var i = 0, tel = testExt.length; i < tel; i++) { + if (isThere("/data/" + md5 + "." + testExt[i])) { + ext = testExt[i]; + break; + } + } + } + } + + // Update the thumbnail with the correct information. + if (md5 && ext) { + var thumbUrl = ""; + var fileUrl = ""; + + if (md5 === "download-preview") { + thumbUrl = "/images/download-preview.png"; + fileUrl = "DDL unavailable for post " + postId + ".jpg" + } + else { + thumbUrl = (ext === "swf" ? "/images/download-preview.png" : "/ssd/data/preview/" + md5 + ".jpg"); + fileUrl = "/data/" + md5 + "." + ext; + } - if (metaInfo) { // Update the thumbnail with the correct information and continue to the next. - var filename = metaInfo[1] || metaInfo[2]; var bcc = bbb.cache.current; var bcs = bbb.cache.stored; - document.getElementById("bbb-img-" + postId).src = metaInfo[0]; + document.getElementById("bbb-img-" + postId).src = thumbUrl; + + if (direct_downloads) + document.getElementById("bbb-ddl-" + postId).href = fileUrl; + bcc.history.push(postId); - bcc.names[postId] = filename; + bcc.names[postId] = md5 + "." + ext; + // Continue to the next image or finish by updating the cache. if (hiddenImgs.length) fetchPages("/posts/" + hiddenImgs[0], "hidden", hiddenImgs); else { @@ -590,13 +637,21 @@ function injectMe() { // This is needed to make this script work in Chrome. var cacheName = bbb.cache.stored.names[post.id]; if (cacheName) { // Load the thumbnail info from the cache. - if (cacheName === "download-preview") + var cacheMd5 = cacheName.split(".")[0]; + var cacheExt = cacheName.split(".")[1]; + + if (cacheName === "download-preview.png") { post.preview_file_url = "/images/download-preview.png"; - else - post.preview_file_url = "/ssd/data/preview/" + cacheName + ".jpg"; + post.file_url = "DDL unavailable for post " + post.id + ".jpg"; + } + else { + post.preview_file_url = (cacheExt === "swf" ? "/images/download-preview.png" : "/ssd/data/preview/" + cacheMd5 + ".jpg"); + post.file_url = "/data/" + cacheName; + } } else { // Provide the hidden image with a placeholder and queue it for fixing. post.preview_file_url = bbbHiddenImg; + post.file_url = "DDL unavailable for post " + post.id + ".jpg"; hiddenImgs.push(post.id); } } @@ -605,7 +660,7 @@ function injectMe() { // This is needed to make this script work in Chrome. thumb = '
' + post.tag_string + '
'; if (direct_downloads) - thumb += 'Direct Download'; + thumb += ''; // Generate output. if (gLoc === "search" || gLoc === "notes" || gLoc === "popular") @@ -2099,7 +2154,18 @@ function injectMe() { // This is needed to make this script work in Chrome. if (isOldVersion(mode)) { switch (mode) { - case "6.0": + case "6.0.2": + // Temporary special case for users that used the test version. + if (/500$/.test(bbb.user.thumb_cache_limit)) + bbb.user.thumb_cache_limit = bbb.options.thumb_cache_limit.def; + + if (!/\.(jpg|gif|png)/.test(localStorage.bbb_thumb_cache)) { + delete localStorage.bbb_thumb_cache; + loadThumbCache(); + } + + if (bbb.user.tag_scrollbars === "false") + bbb.user.tag_scrollbars = 0; break; } @@ -3635,7 +3701,7 @@ function injectMe() { // This is needed to make this script work in Chrome. } // End of injectMe. // Load script into the page so it can access Danbooru's Javascript in Chrome. Thanks to everyone else that has ever had this problem before... and Google which found the answers to their questions for me. -if (document.body) { +if (document.body && Danbooru) { var script = document.createElement('script'); script.type = "text/javascript"; script.appendChild(document.createTextNode('(' + injectMe + ')();')); From 6ed5ac2a5329dd4b4f0f2f95726c1d537cd4efd3 Mon Sep 17 00:00:00 2001 From: Moebius-Strip Date: Sat, 22 Feb 2014 21:45:41 -0500 Subject: [PATCH 08/10] Comment changes * Changed the comment section method to one more similar to the current listing one. --- better-better-booru.user.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/better-better-booru.user.js b/better-better-booru.user.js index 4a2ed25..8a18ec4 100644 --- a/better-better-booru.user.js +++ b/better-better-booru.user.js @@ -427,15 +427,15 @@ function injectMe() { // This is needed to make this script work in Chrome. var comments = commentSection.getElementsByClassName("comment"); var numComments = comments.length; var toShow = 6; // Number of comments to display. - var metaInfo = /\/ssd\/data\/preview\/(\w+)\.jpg/.exec(xmlhttp.responseText); + var previewInfo = document.evaluate('.//meta[@property="og:image"]', childSpan, null, 9, null).singleNodeValue; var previewImg = post.getElementsByTagName("img")[0]; target = post.getElementsByClassName("comments-for-post")[0]; newContent = document.createDocumentFragment(); // Fix the image. - if (metaInfo && previewImg) { - previewImg.src = metaInfo[0]; - previewImg.alt = metaInfo[1]; + if (previewInfo && previewImg) { + previewImg.src = previewInfo.content; + previewImg.alt = /(\w+)\.\w+$/.exec(previewInfo.content)[1]; } // Fix the comments. From 50ac06c85274e7f9f7c587bd0110bc40b6856616 Mon Sep 17 00:00:00 2001 From: Moebius-Strip Date: Sat, 22 Feb 2014 23:14:37 -0500 Subject: [PATCH 09/10] Version 6.1 --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index ac8398d..29eb184 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,12 @@ Various tweaks to make Danbooru better. Changelog ---------- +* Version 6.1: + * Added a "tag list srollbars" option to limit the length of a post's tag list(s). + * Added a "thumbnail info cache limit" option to limit the size of the hidden post cache. + * Added an icon to the script for the browser's script handling add-on/extension (Greasemonkey, Tampermonkey, etc). + * Updated "custom tag borders" to support banned as a status match (status:banned). + * Updated/fixed hidden post display to support Danbooru's API changes. * Version 6.0.2: * Updated custom tag borders to support Danbooru's status border changes. * Version 6.0.1: From eb88b6855c64fc8264b0fc0c3affe449f9de3df6 Mon Sep 17 00:00:00 2001 From: Moebius-Strip Date: Sat, 22 Feb 2014 23:15:15 -0500 Subject: [PATCH 10/10] Version 6.1 --- better-better-booru.user.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/better-better-booru.user.js b/better-better-booru.user.js index 8a18ec4..acb51aa 100644 --- a/better-better-booru.user.js +++ b/better-better-booru.user.js @@ -1,8 +1,8 @@ // ==UserScript== -// @name better_better_booru_test +// @name better_better_booru // @author otani, modified by Jawertae, A Pseudonymous Coder & Moebius Strip. // @description Several changes to make Danbooru much better. Including the viewing of loli/shota images on non-upgraded accounts and more. -// @version 6.0.2 +// @version 6.1 // @updateURL https://userscripts.org/scripts/source/100614.meta.js // @downloadURL https://userscripts.org/scripts/source/100614.user.js // @match http://*.donmai.us/* @@ -38,7 +38,7 @@ function injectMe() { // This is needed to make this script work in Chrome. translationMode: false }, options: { // Setting options and data. - bbb_version: "6.0.2", + bbb_version: "6.1", alternate_image_swap: new Option("checkbox", false, "Alternate Image Swap", "Switch between the sample and original image by clicking the image. Notes can be toggled by using the link in the sidebar options section."), arrow_nav: new Option("checkbox", false, "Arrow Navigation", "Allow the use of the left and right arrow keys to navigate pages. Has no effect on individual posts."), autohide_sidebar: new Option("dropdown", "none", "Auto-hide Sidebar", "Hide the sidebar for individual posts and/or searches until the mouse comes close to the left side of the window or the sidebar gains focus.

Tips
By using Danbooru's keyboard shortcut for the letter \"Q\" to place focus on the search box, you can unhide the sidebar.

Use the thumbnail count option to get the most out of this feature on search listings.", {txtOptions:["Disabled:none", "Searches:search", "Posts:post", "Searches & Posts:post search"]}),