From 667ebf298b1f79d4d142cb38576dbd7a135ad9c5 Mon Sep 17 00:00:00 2001 From: Moebius-Strip Date: Thu, 21 Dec 2017 20:24:10 -0500 Subject: [PATCH 01/11] Hide favorite button option * Added an option to hide the favorite button below post content. --- better-better-booru.user.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/better-better-booru.user.js b/better-better-booru.user.js index d0b835f..671b4f6 100644 --- a/better-better-booru.user.js +++ b/better-better-booru.user.js @@ -353,6 +353,7 @@ function bbbScript() { // Wrapper for injecting the script into the document. fixed_sidebar: newOption("dropdown", "none", "Fixed Sidebar", "Make the sidebar never completely vertically scroll out of view for posts, favorites listings, and/or searches by fixing it to the top or bottom of the window when it would normally start scrolling out of view. NoteThe \"auto-hide sidebar\" option will override this option if both try to modify the same page. TipDepending on the available height in the browser window and the Danbooru location being modified, the \"tag scrollbars\", \"collapsible sidebar\", and/or \"remove tag headers\" options may be needed for best results.", {txtOptions:["Disabled:none", "Favorites:favorites", "Posts:post", "Searches:search", "Favorites & Posts:favorites post", "Favorites & Searches:favorites search", "Posts & Searches:post search", "All:favorites post search"]}), hide_ban_notice: newOption("checkbox", false, "Hide Ban Notice", "Hide the Danbooru ban notice."), hide_comment_notice: newOption("checkbox", false, "Hide Comment Guide Notice", "Hide the Danbooru comment guide notice."), + hide_fav_button: newOption ("checkbox", false, "Hide Favorite Button", "Hide the favorite button below post content."), hide_pool_notice: newOption("checkbox", false, "Hide Pool Guide Notice", "Hide the Danbooru pool guide notice."), hide_sign_up_notice: newOption("checkbox", false, "Hide Sign Up Notice", "Hide the Danbooru account sign up notice."), hide_tag_notice: newOption("checkbox", false, "Hide Tag Guide Notice", "Hide the Danbooru tag guide notice."), @@ -421,7 +422,7 @@ function bbbScript() { // Wrapper for injecting the script into the document. notices: newSection("general", ["show_resized_notice", "minimize_status_notices", "hide_sign_up_notice", "hide_upgrade_notice", "hide_hidden_notice", "hide_tos_notice", "hide_comment_notice", "hide_tag_notice", "hide_upload_notice", "hide_pool_notice", "hide_ban_notice"], "Notices"), sidebar: newSection("general", ["remove_tag_headers", "post_tag_scrollbars", "search_tag_scrollbars", "autohide_sidebar", "fixed_sidebar", "collapse_sidebar"], "Tag Sidebar"), misc: newSection("general", ["direct_downloads", "track_new", "clean_links", "post_tag_titles", "search_add", "page_counter", "comment_score", "quick_search"], "Misc."), - misc_layout: newSection("general", ["fixed_paginator"], "Misc."), + misc_layout: newSection("general", ["fixed_paginator", "hide_fav_button"], "Misc."), script_settings: newSection("general", ["bypass_api", "manage_cookies", "enable_status_message", "enable_menu_autocomplete", "resize_link_style", "override_blacklist", "override_resize", "override_sample", "disable_tagged_filenames", "thumbnail_count_default"], "Script Settings"), status_borders: newSection("border", "status_borders", "Custom Status Borders", "When using custom status borders, the borders can be edited here. For easy color selection, use one of the many free tools on the internet like this one."), tag_borders: newSection("border", "tag_borders", "Custom Tag Borders", "When using custom tag borders, the borders can be edited here. For easy color selection, use one of the many free tools on the internet like this one.") @@ -489,6 +490,7 @@ function bbbScript() { // Wrapper for injecting the script into the document. var disable_tagged_filenames = bbb.user.disable_tagged_filenames; var track_new = bbb.user.track_new; + var hide_fav_button = bbb.user.hide_fav_button; var show_resized_notice = bbb.user.show_resized_notice; var hide_sign_up_notice = bbb.user.hide_sign_up_notice; var hide_upgrade_notice = bbb.user.hide_upgrade_notice; @@ -7792,6 +7794,9 @@ function bbbScript() { // Wrapper for injecting the script into the document. if (hide_hidden_notice) styles += '.hidden-posts-notice {display: none !important;}'; + if (hide_fav_button) + styles += '.fav-buttons {display: none !important;}'; + customStyles.innerHTML = styles; document.getElementsByTagName("head")[0].appendChild(customStyles); } From f3349ea90006542f0301866e6b812bac7bbf01d7 Mon Sep 17 00:00:00 2001 From: Moebius-Strip Date: Thu, 21 Dec 2017 20:45:44 -0500 Subject: [PATCH 02/11] Add random post link option * Added an option to put the random link and hotkey back for individual posts. --- better-better-booru.user.js | 39 ++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/better-better-booru.user.js b/better-better-booru.user.js index 671b4f6..8e77b90 100644 --- a/better-better-booru.user.js +++ b/better-better-booru.user.js @@ -316,6 +316,7 @@ function bbbScript() { // Wrapper for injecting the script into the document. }, options: { // Setting options and data. bbb_version: "8.0.2", + add_random_post_link: newOption("checkbox", false, "Add Random Link", "Add a link to a random post to the post sidebar options menu."), alternate_image_swap: newOption("checkbox", false, "Alternate Image Swap", "Switch between the sample and original image by clicking the image. NoteNotes can be toggled by using the link in the sidebar options section."), autohide_sidebar: newOption("dropdown", "none", "Auto-hide Sidebar", "Hide the sidebar for posts, favorites listings, and/or searches until the mouse comes close to the left side of the window or the sidebar gains focus.TipsBy using Danbooru's hotkey 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", "Favorites:favorites", "Posts:post", "Searches:search", "Favorites & Posts:favorites post", "Favorites & Searches:favorites search", "Posts & Searches:post search", "All:favorites post search"]}), autoscroll_post: newOption("dropdown", "none", "Auto-scroll Post", "Automatically scroll a post to a particular point. Below Header: Scroll the window down until the header is no longer visible or scrolling is no longer possible. Post Content: Position the post content as close as possible to the left and top edges of the window viewport when initially loading a post. Using this option will also scroll past any notices above the content.", {txtOptions:["Disabled:none", "Below Header:header", "Post Content:post"]}), @@ -422,7 +423,7 @@ function bbbScript() { // Wrapper for injecting the script into the document. notices: newSection("general", ["show_resized_notice", "minimize_status_notices", "hide_sign_up_notice", "hide_upgrade_notice", "hide_hidden_notice", "hide_tos_notice", "hide_comment_notice", "hide_tag_notice", "hide_upload_notice", "hide_pool_notice", "hide_ban_notice"], "Notices"), sidebar: newSection("general", ["remove_tag_headers", "post_tag_scrollbars", "search_tag_scrollbars", "autohide_sidebar", "fixed_sidebar", "collapse_sidebar"], "Tag Sidebar"), misc: newSection("general", ["direct_downloads", "track_new", "clean_links", "post_tag_titles", "search_add", "page_counter", "comment_score", "quick_search"], "Misc."), - misc_layout: newSection("general", ["fixed_paginator", "hide_fav_button"], "Misc."), + misc_layout: newSection("general", ["fixed_paginator", "hide_fav_button", "add_random_post_link"], "Misc."), script_settings: newSection("general", ["bypass_api", "manage_cookies", "enable_status_message", "enable_menu_autocomplete", "resize_link_style", "override_blacklist", "override_resize", "override_sample", "disable_tagged_filenames", "thumbnail_count_default"], "Script Settings"), status_borders: newSection("border", "status_borders", "Custom Status Borders", "When using custom status borders, the borders can be edited here. For easy color selection, use one of the many free tools on the internet like this one."), tag_borders: newSection("border", "tag_borders", "Custom Tag Borders", "When using custom tag borders, the borders can be edited here. For easy color selection, use one of the many free tools on the internet like this one.") @@ -490,6 +491,7 @@ function bbbScript() { // Wrapper for injecting the script into the document. var disable_tagged_filenames = bbb.user.disable_tagged_filenames; var track_new = bbb.user.track_new; + var add_random_post_link = bbb.user.add_random_post_link; var hide_fav_button = bbb.user.hide_fav_button; var show_resized_notice = bbb.user.show_resized_notice; var hide_sign_up_notice = bbb.user.hide_sign_up_notice; @@ -806,6 +808,9 @@ function bbbScript() { // Wrapper for injecting the script into the document. // Enable the "Toggle Notes", "Random Post", and "Find similar" options for logged out users. fixOptionsSection(); + // Add the random post link. + addRandomPostLink(); + // Replace the "resize to window" link with new resize links. modifyResizeLink(); @@ -825,6 +830,9 @@ function bbbScript() { // Wrapper for injecting the script into the document. // Fix the post links in the sidebar. fixPostDownloadLinks(); + // Add the random post link. + addRandomPostLink(); + // Replace the "resize to window" link with new resize links. modifyResizeLink(); @@ -3798,6 +3806,35 @@ function bbbScript() { // Wrapper for injecting the script into the document. optionsSection.innerHTML = '

Options

'; } + function addRandomPostLink() { + // Add the random post link and hotkey back to posts. + var optionListItem = document.getElementById("add-to-pool-list") || document.getElementById("add-notes-list") || document.getElementById("add-artist-commentary-list"); + + if (!optionListItem || !add_random_post_link || gLoc !== "post") + return; + + // Create the link. + var searchTags = getVar("tags"); + + var randomListItem = document.createElement("li"); + randomListItem.id = "random-post-list"; + + var randomLink = document.createElement("a"); + randomLink.id = "random-post"; + randomLink.href = "/posts/random" + (searchTags ? "?tags=" + searchTags : ""); + randomLink.innerHTML = "Random post"; + randomListItem.appendChild(randomLink); + + optionListItem.parentNode.insertBefore(randomListItem, optionListItem); + + // Create the hotkey. + function randomHotkey() { + location.href = randomLink.href; + } + + createHotkey("82", randomHotkey); // R + } + function fixPostDownloadLinks() { // Fix the "size" and "download" links in the sidebar by creating the download link for logged out users (when able) and handling tagged filenames as necessary for all users. var postInfo = bbb.post.info; From 650630b621945ca60fa6114284168a50a5ac8b9e Mon Sep 17 00:00:00 2001 From: Moebius-Strip Date: Thu, 21 Dec 2017 20:46:59 -0500 Subject: [PATCH 03/11] Add popular link option * Added an option to put the popular link back in the posts submenu. --- better-better-booru.user.js | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/better-better-booru.user.js b/better-better-booru.user.js index 8e77b90..59a47ac 100644 --- a/better-better-booru.user.js +++ b/better-better-booru.user.js @@ -316,6 +316,7 @@ function bbbScript() { // Wrapper for injecting the script into the document. }, options: { // Setting options and data. bbb_version: "8.0.2", + add_popular_link: newOption("checkbox", false, "Add Popular Link", "Add a link to the popular listing to the \"posts\" submenu"), add_random_post_link: newOption("checkbox", false, "Add Random Link", "Add a link to a random post to the post sidebar options menu."), alternate_image_swap: newOption("checkbox", false, "Alternate Image Swap", "Switch between the sample and original image by clicking the image. NoteNotes can be toggled by using the link in the sidebar options section."), autohide_sidebar: newOption("dropdown", "none", "Auto-hide Sidebar", "Hide the sidebar for posts, favorites listings, and/or searches until the mouse comes close to the left side of the window or the sidebar gains focus.TipsBy using Danbooru's hotkey 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", "Favorites:favorites", "Posts:post", "Searches:search", "Favorites & Posts:favorites post", "Favorites & Searches:favorites search", "Posts & Searches:post search", "All:favorites post search"]}), @@ -423,7 +424,7 @@ function bbbScript() { // Wrapper for injecting the script into the document. notices: newSection("general", ["show_resized_notice", "minimize_status_notices", "hide_sign_up_notice", "hide_upgrade_notice", "hide_hidden_notice", "hide_tos_notice", "hide_comment_notice", "hide_tag_notice", "hide_upload_notice", "hide_pool_notice", "hide_ban_notice"], "Notices"), sidebar: newSection("general", ["remove_tag_headers", "post_tag_scrollbars", "search_tag_scrollbars", "autohide_sidebar", "fixed_sidebar", "collapse_sidebar"], "Tag Sidebar"), misc: newSection("general", ["direct_downloads", "track_new", "clean_links", "post_tag_titles", "search_add", "page_counter", "comment_score", "quick_search"], "Misc."), - misc_layout: newSection("general", ["fixed_paginator", "hide_fav_button", "add_random_post_link"], "Misc."), + misc_layout: newSection("general", ["fixed_paginator", "hide_fav_button", "add_popular_link", "add_random_post_link"], "Misc."), script_settings: newSection("general", ["bypass_api", "manage_cookies", "enable_status_message", "enable_menu_autocomplete", "resize_link_style", "override_blacklist", "override_resize", "override_sample", "disable_tagged_filenames", "thumbnail_count_default"], "Script Settings"), status_borders: newSection("border", "status_borders", "Custom Status Borders", "When using custom status borders, the borders can be edited here. For easy color selection, use one of the many free tools on the internet like this one."), tag_borders: newSection("border", "tag_borders", "Custom Tag Borders", "When using custom tag borders, the borders can be edited here. For easy color selection, use one of the many free tools on the internet like this one.") @@ -491,6 +492,7 @@ function bbbScript() { // Wrapper for injecting the script into the document. var disable_tagged_filenames = bbb.user.disable_tagged_filenames; var track_new = bbb.user.track_new; + var add_popular_link = bbb.user.add_popular_link; var add_random_post_link = bbb.user.add_random_post_link; var hide_fav_button = bbb.user.hide_fav_button; var show_resized_notice = bbb.user.show_resized_notice; @@ -559,6 +561,8 @@ function bbbScript() { // Wrapper for injecting the script into the document. thumbInfo(); + addPopularLink(); + removeTagHeaders(); searchAdd(); @@ -9445,6 +9449,24 @@ function bbbScript() { // Wrapper for injecting the script into the document. event.preventDefault(); } + function addPopularLink() { + // Add the popular link back to the posts submenu. + var subListItem = document.getElementById("secondary-links-posts-hot") || document.getElementById("secondary-links-posts-favorites"); + + if (!subListItem || !add_popular_link) + return; + + var popularListItem = document.createElement("li"); + popularListItem.id = "secondary-links-posts-popular"; + + var popularLink = document.createElement("a"); + popularLink.href = "/explore/posts/popular"; + popularLink.innerHTML = "Popular"; + popularListItem.appendChild(popularLink); + + subListItem.parentNode.insertBefore(popularListItem, subListItem); + } + function eraseSettingDialog() { // Open a dialog box for erasing various BBB information. var options = [ From b3805f9613abe8366e5978a44eb23249965d422d Mon Sep 17 00:00:00 2001 From: Moebius-Strip Date: Wed, 31 Jan 2018 20:56:05 -0500 Subject: [PATCH 04/11] Tagged filename fixes * Fixed the insertion of the description tags into sample URLs. * Removed the insertion of the description tags into raikou1 server URLs since it broke them. --- 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 59a47ac..e18442d 100644 --- a/better-better-booru.user.js +++ b/better-better-booru.user.js @@ -6383,9 +6383,9 @@ function bbbScript() { // Wrapper for injecting the script into the document. postInfo.file_img_src = postInfo.file_url.replace(postInfo.file_url_desc, ""); postInfo.large_file_img_src = postInfo.large_file_url.replace(postInfo.file_url_desc, ""); } - else if (!disable_tagged_filenames && postInfo.file_url.indexOf("__") < 0) { - postInfo.file_img_src = postInfo.file_url.replace(/\/(?=[\w\_]+\.\w+$)/, "/" + postInfo.file_url_desc); - postInfo.large_file_img_src = postInfo.large_file_url.replace(/\/(?=[\w\_]+\.\w+$)/, "/" + postInfo.file_url_desc); + else if (!disable_tagged_filenames && postInfo.file_url.indexOf("__") < 0 && postInfo.file_url.indexOf("raikou1.donmai.us") < 0) { + postInfo.file_img_src = postInfo.file_url.replace(/\/(?=[\w\-]+\.\w+$)/, "/" + postInfo.file_url_desc); + postInfo.large_file_img_src = postInfo.large_file_url.replace(/\/(?=[\w\-]+\.\w+$)/, "/" + postInfo.file_url_desc); } else { postInfo.file_img_src = postInfo.file_url; From 8af251ff445b7620b6cfaa9f33ac85c7bd343727 Mon Sep 17 00:00:00 2001 From: Moebius-Strip Date: Wed, 7 Feb 2018 19:21:44 -0500 Subject: [PATCH 05/11] Custom pool metatag values * Added the custom pool metatag values to the personalized autocomplete. --- better-better-booru.user.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/better-better-booru.user.js b/better-better-booru.user.js index e18442d..8c71c30 100644 --- a/better-better-booru.user.js +++ b/better-better-booru.user.js @@ -10052,6 +10052,7 @@ function bbbScript() { // Wrapper for injecting the script into the document. Danbooru.Autocomplete.static_metatags.group = Danbooru.Autocomplete.static_metatags.g = groups; Danbooru.Autocomplete.static_metatags.parent = ["any", "none"]; Danbooru.Autocomplete.static_metatags.isfav = ["true", "false"]; + Danbooru.Autocomplete.static_metatags.pool = ["series", "collection", "any", "none", "active", "inactive"]; // Counter normal autocomplete getting turned back on after submitting an input. document.body.addEventListener("focus", function(event) { @@ -10128,6 +10129,7 @@ function bbbScript() { // Wrapper for injecting the script into the document. case "group": case "g": case "isfav": + case "pool": Danbooru.Autocomplete.static_metatag_source(term, resp, metatag); return; } From 20efb03724529f785eff86f2f34afce54a788e5f Mon Sep 17 00:00:00 2001 From: Moebius-Strip Date: Thu, 8 Feb 2018 19:04:38 -0500 Subject: [PATCH 06/11] Group tag operator fix * Fixed group metatags not being able to use "or" (~) and "exclude" (-) at the same time. --- 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 8c71c30..5fe9070 100644 --- a/better-better-booru.user.js +++ b/better-better-booru.user.js @@ -7127,7 +7127,7 @@ function bbbScript() { // Wrapper for injecting the script into the document. if (string.indexOf("BBBPARENS") < 0) { // Replace parentheses that are not part of a tag with placeholders. - var parensRegex = /(?:^|([\s,]))([-~])*\(%?(?=$|[\s,])|(?:^|([\s,]))%?\)(?=$|[\s,])/; + var parensRegex = /(?:^|([\s,]))([-~]*)\(%?(?=$|[\s,])|(?:^|([\s,]))%?\)(?=$|[\s,])/; if (!parensRegex.test(string)) return {search: string, groups: []}; @@ -7147,7 +7147,7 @@ function bbbScript() { // Wrapper for injecting the script into the document. // Remove unpaired opening parentheses near the end of the search. while (parens[parens.length - 1] === "BBBPARENSOPEN") { - searchString = searchString.replace(/^(.*\s)?[~-]*\BBBPARENSOPEN/, "$1"); + searchString = searchString.replace(/^(.*\s)?[~-]*BBBPARENSOPEN/, "$1"); parens.pop(); } @@ -7182,7 +7182,7 @@ function bbbScript() { // Wrapper for injecting the script into the document. groups.push(groupMatch.substring(13, groupMatch.length - 14)); } else if (!nextParen && startCount > 0 && endCount === 0 ) // Remove leftover unpaired opening parentheses. - searchString = searchString.replace(/^(.*\s)?[~-]*\BBBPARENSOPEN/, "$1"); + searchString = searchString.replace(/^(.*\s)?[~-]*BBBPARENSOPEN/, "$1"); } return {search: searchString, groups: groups}; From 4afd519c54b3148ed4cbd2f888d5232b190e017b Mon Sep 17 00:00:00 2001 From: Moebius-Strip Date: Tue, 20 Mar 2018 13:14:41 -0400 Subject: [PATCH 07/11] Raikou server fix update * Allow tagged filenames to work on the raikou server again since Danbooru has fixed the server problem. --- better-better-booru.user.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/better-better-booru.user.js b/better-better-booru.user.js index 5fe9070..1d2bde6 100644 --- a/better-better-booru.user.js +++ b/better-better-booru.user.js @@ -6383,7 +6383,7 @@ function bbbScript() { // Wrapper for injecting the script into the document. postInfo.file_img_src = postInfo.file_url.replace(postInfo.file_url_desc, ""); postInfo.large_file_img_src = postInfo.large_file_url.replace(postInfo.file_url_desc, ""); } - else if (!disable_tagged_filenames && postInfo.file_url.indexOf("__") < 0 && postInfo.file_url.indexOf("raikou1.donmai.us") < 0) { + else if (!disable_tagged_filenames && postInfo.file_url.indexOf("__") < 0) { postInfo.file_img_src = postInfo.file_url.replace(/\/(?=[\w\-]+\.\w+$)/, "/" + postInfo.file_url_desc); postInfo.large_file_img_src = postInfo.large_file_url.replace(/\/(?=[\w\-]+\.\w+$)/, "/" + postInfo.file_url_desc); } @@ -10253,4 +10253,4 @@ function bbbInit() { window.setTimeout(function() { document.body.removeChild(script); }, 0); } -bbbInit(); \ No newline at end of file +bbbInit(); From 5f0a6d990f05b35168f42b48fc1f65b767be22fc Mon Sep 17 00:00:00 2001 From: Moebius-Strip Date: Thu, 5 Apr 2018 21:34:04 -0400 Subject: [PATCH 08/11] Scrape updates for better error protection * Added default values for potentially missing attributes. * Made sure to always provide the most information available. --- better-better-booru.user.js | 57 +++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 25 deletions(-) diff --git a/better-better-booru.user.js b/better-better-booru.user.js index 1d2bde6..bcfd862 100644 --- a/better-better-booru.user.js +++ b/better-better-booru.user.js @@ -169,8 +169,15 @@ function bbbScript() { // Wrapper for injecting the script into the document. return this.getAttribute("data-" + name); else if (this.bbbHasClass("post-preview")) return scrapeThumb(this); - else - return scrapePost(this); + else { + // Always try to send the HTML element in order to provide the most information. + var parent = this; + + while (parent.parentNode) + parent = parent.parentNode; + + return scrapePost(parent); + } }; document.bbbInfo = function(name, value) { @@ -1402,32 +1409,32 @@ function bbbScript() { // Wrapper for injecting the script into the document. var postEl = postContent.el; var postTag = (postEl ? postEl.tagName : undefined); - var flags = imgContainer.getAttribute("data-flags"); + var flags = imgContainer.getAttribute("data-flags") || ""; var imgInfo = { - md5: imgContainer.getAttribute("data-md5"), - file_ext: imgContainer.getAttribute("data-file-ext"), - file_url: imgContainer.getAttribute("data-file-url"), - large_file_url: imgContainer.getAttribute("data-large-file-url"), - preview_file_url: imgContainer.getAttribute("data-preview-file-url"), + md5: imgContainer.getAttribute("data-md5") || "", + file_ext: imgContainer.getAttribute("data-file-ext") || "", + file_url: imgContainer.getAttribute("data-file-url") || "", + large_file_url: imgContainer.getAttribute("data-large-file-url") || "", + preview_file_url: imgContainer.getAttribute("data-preview-file-url") || "", has_large: undefined, - id: Number(imgContainer.getAttribute("data-id")), + id: Number(imgContainer.getAttribute("data-id")) || 0, pixiv_id: Number(imgContainer.getAttribute("data-pixiv-id")) || null, - fav_count: Number(imgContainer.getAttribute("data-fav-count")), + fav_count: Number(imgContainer.getAttribute("data-fav-count")) || 0, has_children: (imgContainer.getAttribute("data-has-children") === "true"), has_active_children: (postTag === "IMG" || postTag === "CANVAS" ? postEl.getAttribute("data-has-active-children") === "true" : !!target.getElementsByClassName("notice-parent")[0]), fav_string: getMeta("favorites", docEl), 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")), - source: imgContainer.getAttribute("data-source"), - tag_string: imgContainer.getAttribute("data-tags"), + rating: imgContainer.getAttribute("data-rating") || "", + score: Number(imgContainer.getAttribute("data-score")) || 0, + source: imgContainer.getAttribute("data-source") || "", + tag_string: imgContainer.getAttribute("data-tags") || "", tag_string_artist: scrapePostTags("artist", target), tag_string_character: scrapePostTags("character", target), tag_string_copyright: scrapePostTags("copyright", target), tag_string_general: scrapePostTags("general", target), - pool_string: imgContainer.getAttribute("data-pools"), - uploader_name: imgContainer.getAttribute("data-uploader"), + pool_string: imgContainer.getAttribute("data-pools") || "", + uploader_name: imgContainer.getAttribute("data-uploader") || "", approver_id: imgContainer.getAttribute("data-approver-id") || null, is_deleted: (flags.indexOf("deleted") > -1), is_flagged: (flags.indexOf("flagged") > -1), @@ -1486,7 +1493,7 @@ function bbbScript() { // Wrapper for injecting the script into the document. function scrapeThumb(post) { // Retrieve info from a thumbnail and return it as API styled info. Mainly for remaking thumbnails. - var flags = post.getAttribute("data-flags"); + var flags = post.getAttribute("data-flags") || ""; var imgInfo = { md5: post.getAttribute("data-md5") || "", file_ext: post.getAttribute("data-file-ext") || "", @@ -1495,19 +1502,19 @@ function bbbScript() { // Wrapper for injecting the script into the document. preview_file_url: post.getAttribute("data-preview-file-url") || "", file_url_desc: post.getAttribute("data-file-url-desc") || undefined, has_large: undefined, - id: Number(post.getAttribute("data-id")), + id: Number(post.getAttribute("data-id")) || 0, pixiv_id: Number(post.getAttribute("data-pixiv-id")) || null, - fav_count: Number(post.getAttribute("data-fav-count")), + fav_count: Number(post.getAttribute("data-fav-count")) || 0, has_children: (post.getAttribute("data-has-children") === "true"), has_active_children: post.bbbHasClass("post-status-has-children"), // Assumption. Basically a flag for the children class. fav_string: (post.getAttribute("data-is-favorited") === "true" ? "fav:" + getMeta("current-user-id") : ""), // Faked since thumbnails don't provide the full list of favorites. parent_id: (post.getAttribute("data-parent-id") ? Number(post.getAttribute("data-parent-id")) : null), - rating: post.getAttribute("data-rating"), - score: Number(post.getAttribute("data-score")), - source: post.getAttribute("data-source"), - tag_string: post.getAttribute("data-tags"), - pool_string: post.getAttribute("data-pools"), - uploader_name: post.getAttribute("data-uploader"), + rating: post.getAttribute("data-rating") || "", + score: Number(post.getAttribute("data-score")) || 0, + source: post.getAttribute("data-source") || "", + tag_string: post.getAttribute("data-tags") || "", + pool_string: post.getAttribute("data-pools") || "", + uploader_name: post.getAttribute("data-uploader") || "", approver_id: post.getAttribute("data-approver-id") || null, is_deleted: (flags.indexOf("deleted") > -1), is_flagged: (flags.indexOf("flagged") > -1), From 87126e150cccfd80f541c50803ae0e442d25ee48 Mon Sep 17 00:00:00 2001 From: Moebius-Strip Date: Thu, 5 Apr 2018 23:44:10 -0400 Subject: [PATCH 09/11] Thumbnail description tags update * Removed the description tags from thumbnail listing URL information since Danbooru no longer provides it. --- better-better-booru.user.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/better-better-booru.user.js b/better-better-booru.user.js index bcfd862..0ee7e38 100644 --- a/better-better-booru.user.js +++ b/better-better-booru.user.js @@ -6374,7 +6374,9 @@ function bbbScript() { // Wrapper for injecting the script into the document. function postFileUrlDesc(postInfo) { // Create/return the file URL desc property. - if (typeof(postInfo.file_url_desc) === "string") + if (gLoc !== "post") // Danbooru doesn't provide this information for thumbnail listings. + return ""; + else if (typeof(postInfo.file_url_desc) === "string") return postInfo.file_url_desc; else if (postInfo.file_url.indexOf("__") > -1) return "__" + postInfo.file_url.split("__")[1] + "__"; From f872c3d6b22956c7a95329c728e2998f3e8a666f Mon Sep 17 00:00:00 2001 From: Moebius-Strip Date: Thu, 5 Apr 2018 23:57:30 -0400 Subject: [PATCH 10/11] User metatag help update * Updated the user metatag description in the help tab to reflect that thumbnail listings no longer provide uploader names. --- 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 0ee7e38..ea5462a 100644 --- a/better-better-booru.user.js +++ b/better-better-booru.user.js @@ -2006,7 +2006,7 @@ function bbbScript() { // Wrapper for injecting the script into the document. helpPage.className = "bbb-page"; scrollDiv.appendChild(helpPage); - helpPage.bbbTextSection('Thumbnail Matching Rules', 'For creating thumbnail matching rules, please consult the following examples:
  • tag1 - Match posts with tag1.
  • tag1 tag2 - Match posts with tag1 AND tag2.
  • -tag1 - Match posts without tag1.
  • tag1 -tag2 - Match posts with tag1 AND without tag2.
  • ~tag1 ~tag2 - Match posts with tag1 OR tag2.
  • ~tag1 ~-tag2 - Match posts with tag1 OR without tag2.
  • tag1 ~tag2 ~tag3 - Match posts with tag1 AND either tag2 OR tag3.

Wildcards can be used with any of the above methods:
  • ~tag1* ~-*tag2 - Match posts with tags starting with tag1 or posts without tags ending with tag2.

Multiple match rules can be specified by using commas or separate lines when possible:
  • tag1 tag2, tag3 tag4 - Match posts with tag1 AND tag2 or posts with tag3 AND tag4.
  • tag1 ~tag2 ~tag3, tag4 - Match posts with tag1 AND either tag2 OR tag3 or posts with tag4.

Tags can be nested/grouped together by using parentheses that only have spaces or commas next to them:
  • ( ~tag1 ~tag2 ) ( ~tag3 ~tag3 ) - Match posts with either tag1 OR tag2 AND either tag3 OR tag4.
  • tag1 ( tag2, tag3 tag4 ) - Match posts with tag1 AND tag2 or posts with tag1 AND tag3 AND tag4.
  • tag1 -( tag2 tag3 ) - Match posts with tag1 AND without tag2 AND tag3.
  • tag1 ~tag2 ~( tag3 tag4 ) - Match posts with tag1 and either tag2 OR tag3 AND tag4.

The following metatags are supported:
  • rating:safe - Match posts rated safe. Accepted values include safe, explicit, and questionable.
  • status:pending - Match pending posts. Accepted values include active, pending, flagged, banned, and deleted. Note that flagged posts also count as active posts.
  • user:albert - Match posts made by the user Albert.
  • isfav:true - Match posts favorited under your current account. Accepted values include true and false.
  • group:hidden or g:hidden - Match posts that match the tags in your group named \"hidden\".
  • pool:1 - Match posts that are in the pool with an ID number of 1. Accepted values include pool ID numbers, "series" for posts in series category pools, "collection" for posts in collection category pools, "any" for posts in any pool, "none" for posts not in a pool, "active" for posts in an active (not deleted) pool, and "inactive" for posts only in an inactive (deleted) pool.
  • parent:1 - Match posts that have the post with an ID number of 1 as a parent. Accepted values include post ID numbers, "any" for any posts with a parent, and "none" for posts without a parent.
  • child:any - Match any posts that have children. Accepted values include "any" for any posts with children and "none" for posts without children.
  • id:1 - Match posts with an ID number of 1.
  • score:1 - Match posts with a score of 1.
  • favcount:1 - Match posts with a favorite count of 1.
  • height:1 - Match posts with a height of 1.
  • width:1 - Match posts with a width of 1.

The id, score, favcount, width, and height metatags can also use number ranges for matching:
  • score:<5 - Match posts with a score less than 5.
  • score:>5 - Match posts with a score greater than 5.
  • score:<=5 or score:..5 - Match posts with a score equal to OR less than 5.
  • score:>=5 or score:5.. - Match posts with a score equal to OR greater than 5.
  • score:1..5 - Match posts with a score equal to OR greater than 1 AND equal to OR less than 5.
'); + helpPage.bbbTextSection('Thumbnail Matching Rules', 'For creating thumbnail matching rules, please consult the following examples:
  • tag1 - Match posts with tag1.
  • tag1 tag2 - Match posts with tag1 AND tag2.
  • -tag1 - Match posts without tag1.
  • tag1 -tag2 - Match posts with tag1 AND without tag2.
  • ~tag1 ~tag2 - Match posts with tag1 OR tag2.
  • ~tag1 ~-tag2 - Match posts with tag1 OR without tag2.
  • tag1 ~tag2 ~tag3 - Match posts with tag1 AND either tag2 OR tag3.

Wildcards can be used with any of the above methods:
  • ~tag1* ~-*tag2 - Match posts with tags starting with tag1 or posts without tags ending with tag2.

Multiple match rules can be specified by using commas or separate lines when possible:
  • tag1 tag2, tag3 tag4 - Match posts with tag1 AND tag2 or posts with tag3 AND tag4.
  • tag1 ~tag2 ~tag3, tag4 - Match posts with tag1 AND either tag2 OR tag3 or posts with tag4.

Tags can be nested/grouped together by using parentheses that only have spaces or commas next to them:
  • ( ~tag1 ~tag2 ) ( ~tag3 ~tag3 ) - Match posts with either tag1 OR tag2 AND either tag3 OR tag4.
  • tag1 ( tag2, tag3 tag4 ) - Match posts with tag1 AND tag2 or posts with tag1 AND tag3 AND tag4.
  • tag1 -( tag2 tag3 ) - Match posts with tag1 AND without tag2 AND tag3.
  • tag1 ~tag2 ~( tag3 tag4 ) - Match posts with tag1 and either tag2 OR tag3 AND tag4.

The following metatags are supported:
  • rating:safe - Match posts rated safe. Accepted values include safe, explicit, and questionable.
  • status:pending - Match pending posts. Accepted values include active, pending, flagged, banned, and deleted. Note that flagged posts also count as active posts.
  • user:albert - Match posts made by the user Albert. Note that this tag will only work when viewing posts since Danbooru doesn\'t provide uploader information for thumbnail listings.
  • isfav:true - Match posts favorited under your current account. Accepted values include true and false.
  • group:hidden or g:hidden - Match posts that match the tags in your group named \"hidden\".
  • pool:1 - Match posts that are in the pool with an ID number of 1. Accepted values include pool ID numbers, "series" for posts in series category pools, "collection" for posts in collection category pools, "any" for posts in any pool, "none" for posts not in a pool, "active" for posts in an active (not deleted) pool, and "inactive" for posts only in an inactive (deleted) pool.
  • parent:1 - Match posts that have the post with an ID number of 1 as a parent. Accepted values include post ID numbers, "any" for any posts with a parent, and "none" for posts without a parent.
  • child:any - Match any posts that have children. Accepted values include "any" for any posts with children and "none" for posts without children.
  • id:1 - Match posts with an ID number of 1.
  • score:1 - Match posts with a score of 1.
  • favcount:1 - Match posts with a favorite count of 1.
  • height:1 - Match posts with a height of 1.
  • width:1 - Match posts with a width of 1.

The id, score, favcount, width, and height metatags can also use number ranges for matching:
  • score:<5 - Match posts with a score less than 5.
  • score:>5 - Match posts with a score greater than 5.
  • score:<=5 or score:..5 - Match posts with a score equal to OR less than 5.
  • score:>=5 or score:5.. - Match posts with a score equal to OR greater than 5.
  • score:1..5 - Match posts with a score equal to OR greater than 1 AND equal to OR less than 5.
'); helpPage.bbbTextSection('Hotkeys', 'Posts
  • B - Open BBB menu.
  • 1 - Resize to window.
  • 2 - Resize to window width.
  • 3 - Resize to window height.
  • 4 - Reset/remove resizing.
Note: Numbers refer to the main typing keypad and not the numeric keypad.

General
  • B - Open BBB menu.
  • E - Toggle endless pages.
  • F - Open quick search.
  • Shift + F - Reset quick search.
'); helpPage.bbbTextSection('Questions, Suggestions, or Bugs?', 'If you have any questions, please use the Greasy Fork feedback forums located here. If you\'d like to report a bug or make a suggestion, please create an issue on GitHub here.'); helpPage.bbbTocSection(); From b8f94725dd920f496d53b4fa0b8d69f3d666b29b Mon Sep 17 00:00:00 2001 From: Moebius-Strip Date: Fri, 6 Apr 2018 00:40:48 -0400 Subject: [PATCH 11/11] Version 8.1 --- README.md | 4 +++- better-better-booru.user.js | 10 +++------- changelog.md | 9 +++++++++ 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 4d8f652..360a679 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,9 @@ Features * Fixed sidebar - Fix/stick the sidebar to the left side of the page and prevent it from vertically scrolling out of view. * Collapsible sidebar - Allow sections of the sidebar to be minimized and expanded. * Fixed paginator - Fix/stick the paginator to the bottom of the window and prevent it from scrolling out of view. - * Move save search - Move the "save this search" button into the sidebar. + * Hide favorite button - Remove the button below post content. + * Add random link - Allow random post access from each post. + * Add popular link - Allow easier popular post listing access from most post pages. * Various options for easily modifying status borders to your liking and creating your own secondary custom borders that match images based on your criteria. * Various options for customizing the majority of notices by either altering or hiding them. * Several other miscellaneous options: diff --git a/better-better-booru.user.js b/better-better-booru.user.js index ea5462a..f472f97 100644 --- a/better-better-booru.user.js +++ b/better-better-booru.user.js @@ -3,7 +3,7 @@ // @namespace https://greasyfork.org/scripts/3575-better-better-booru // @author otani, modified by Jawertae, A Pseudonymous Coder & Moebius Strip. // @description Several changes to make Danbooru much better. -// @version 8.0.2 +// @version 8.1 // @updateURL https://greasyfork.org/scripts/3575-better-better-booru/code/better_better_booru.meta.js // @downloadURL https://greasyfork.org/scripts/3575-better-better-booru/code/better_better_booru.user.js // @match *://*.donmai.us/* @@ -322,7 +322,7 @@ function bbbScript() { // Wrapper for injecting the script into the document. swapped: false // Whether the post content has been changed between the original and sample versions. }, options: { // Setting options and data. - bbb_version: "8.0.2", + bbb_version: "8.1", add_popular_link: newOption("checkbox", false, "Add Popular Link", "Add a link to the popular listing to the \"posts\" submenu"), add_random_post_link: newOption("checkbox", false, "Add Random Link", "Add a link to a random post to the post sidebar options menu."), alternate_image_swap: newOption("checkbox", false, "Alternate Image Swap", "Switch between the sample and original image by clicking the image. NoteNotes can be toggled by using the link in the sidebar options section."), @@ -3366,11 +3366,7 @@ function bbbScript() { // Wrapper for injecting the script into the document. deleteData("bbb_thumb_cache"); case "8.0": case "8.0.1": - if (reason !== "backup") { - cleanLocalStorage("autocomplete"); - localStorage.bbbSetItem("bbb_settings", JSON.stringify(bbb.user)); - bbbNotice("Upon the release of Firefox 57 and the move over to Greasemonkey 4, BBB will not be able to fully support Greasemonkey due to decisions the developers have made about loading and saving data. Greasemonkey users will have to revert back to using an older storage method that will still work while suffering a few disadvantages. Those disadvantages include: 1) A much more limited amount of space for storage. 2) The inability to have your settings persist across all Danbooru subdomains and during private browsing. If you are reading this, a copy of your settings has already been saved using the old method, but it is advised that you create a separate backup before updating to Firefox 57 to collect any new changes and/or guard against any unforeseen problems.", 0); - } + case "8.0.2": break; } diff --git a/changelog.md b/changelog.md index 1542c83..865d3f5 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,14 @@ Changelog ---------- +* Version 8.1: + * Added a "hide favorite button" layout option for hiding the button underneath post content. + * Added an "add random link" layout option for placing a link to a random post in the sidebar options menu of posts. + * Added an "add popular link" layout option for placing a link to the popular listing in the submenu of the posts section. + * Added the custom pool metatag values ("active", etc.) to tag autocomplete. + * Updated to support Danbooru removing uploader names from thumbnail listings ("user" metatag will no longer work on them). + * Updated to support Danbooru removing description tags from thumbnail listing information. + * Fixed the insertion of description tags into sample post URLs. + * Fixed the operators for the "group" metatag so that both "or" (~) and "exclude" (-) can be used at the same time. * Version 8.0.2: * Updated to notify Greasemonkey users about the upcoming changes Firefox 57 and Greasemonkey 4 will bring. * Version 8.0.1: