diff --git a/better-better-booru.user.js b/better-better-booru.user.js
index 57f6134..faa7aa1 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.2
+// @version 8.2.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/*
@@ -73,6 +73,23 @@ function bbbScript() { // Wrapper for injecting the script into the document.
return encoded;
};
+ Element.prototype.bbbParent = function(parentName, limit) {
+ // Search an element's successive parent nodes for a specific tag name or until the amount limit is hit.
+ var el = this;
+ var search = parentName.toUpperCase();
+
+ for (var i = 0, il = limit || 1; i < il; i++) {
+ var parent = el.parentNode;
+
+ if (parent && parent.tagName === search)
+ return parent;
+ else
+ el = parent;
+ }
+
+ return null;
+ };
+
Element.prototype.bbbGetPadding = function() {
// Get all the padding measurements of an element including the total width and height.
if (window.getComputedStyle) {
@@ -340,7 +357,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.2",
+ bbb_version: "8.2.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."),
@@ -370,7 +387,7 @@ function bbbScript() { // Wrapper for injecting the script into the document.
enable_status_message: newOption("checkbox", true, "Enable Status Message", "When requesting information from Danbooru, display the request status in the lower right corner."),
endless_default: newOption("dropdown", "disabled", "Default", "Enable endless pages on the favorites, search, pool, and favorite group listings. Off: Start up with all features off. On: Start up with all features on.Paused: Start up with all features on, but do not append new pages until the \"load more\" button is clicked. NoteWhen not set to disabled, endless pages can be toggled between off and on/paused by using the \"E\" hotkey or the \"endless\" link next to the \"listing\" link in the page submenu. TipThe \"new tab/window\" and \"fixed paginator\" options can provide additional customization for endless pages.", {txtOptions:["Disabled:disabled", "Off:off", "On:on", "Paused:paused"]}),
endless_fill: newOption("checkbox", false, "Fill Pages", "When appending pages with missing thumbnails caused by hidden posts or removed duplicate posts, retrieve thumbnails from the following pages and add them to the new page until the desired number of thumbnails is reached. NoteIf using page separators, the displayed page number for appended pages composed of thumbnails from multiple Danbooru pages will be replaced by a range consisting of the first and last pages from which thumbnails were retrieved."),
- endless_pause_interval: newOption("dropdown", 0, "Pause Interval", "Pause endless pages each time the number of pages reaches a multiple of the selected amount.", {txtOptions:["Disabled:0"], numRange:[1,100]}),
+ endless_pause_interval: newOption("dropdown", 0, "Pause Interval", "Pause endless pages each time the number of pages reaches a multiple of the selected amount. Note When this option is enabled, the \"Shift + E\" hotkey can be used to continue loading more pages after pausing.", {txtOptions:["Disabled:0"], numRange:[1,100]}),
endless_preload: newOption("checkbox", false, "Preload Next Page", "Start loading the next page as soon as possible.NoteA preloaded page will not be appended until the scroll limit is reached."),
endless_remove_dup: newOption("checkbox", false, "Remove Duplicates", "When appending new pages, remove posts that already exist in the listing from the new page.NoteDuplicate posts are caused by the addition of new posts to the beginning of a listing or changes to the order of the posts."),
endless_scroll_limit: newOption("dropdown", 500, "Scroll Limit", "Set the minimum amount of pixels that the window can have left to vertically scroll before it starts appending the next page.", {numList:[0,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]}),
@@ -402,7 +419,7 @@ function bbbScript() { // Wrapper for injecting the script into the document.
post_resize_mode: newOption("dropdown", "width", "Resize Mode", "Choose how to shrink large post content to fit the browser window when initially loading a post.", {txtOptions:["Width:width", "Height:height", "Width & Height:all"]}),
post_tag_scrollbars: newOption("dropdown", 0, "Post Tag Scrollbars", "Limit the length of the sidebar tag lists for 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.NoteWhen 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]}),
post_tag_titles: newOption("checkbox", false, "Post Tag Titles", "Change the page titles for posts to a full list of the post tags."),
- quick_search: newOption("dropdown", "disabled", "Quick Search", "Add a new search box to the upper right corner of the window viewport that allows searching through the current thumbnails for specific posts. Fade: Fade all posts that don't match in the thumbnail listing. Remove: Remove all posts that don't match from the thumbnail listing. DirectionsPlease read the \"thumbnail matching rules\" section under the help tab for information about creating searches.
The search starts minimized in the upper right corner. Left clicking the main icon will open and close the search. Right clicking the main icon will completely reset the search. Holding down shift while left clicking the main icon will toggle an active search's pinned status.
While open, the search can be entered/updated in the search box and the pinned status can be toggled by clicking the pushpin icon. Clicking the negative icon next to the pushpin icon will tell quick search to negate/invert the search being submitted. If no changes are made to an active search, submitting it a second time will reset the quick search. NotesOptions labeled with \"pinned\" will make searches default to being pinned.
A pinned search will persist across other pages in the same browsing session for that tab until it ends or the search is unpinned.
When not set to disabled, the quick search can be opened by using the \"F\" hotkey. Additionally, an active search can be reset by using \"Shift + F\". Pressing \"Escape\" while the quick search is open will close it.", {txtOptions:["Disabled:disabled", "Fade:fade", "Fade (Pinned):fade pinned", "Remove:remove", "Remove (Pinned):remove pinned"]}),
+ quick_search: newOption("dropdown", "disabled", "Quick Search", "Add a new search box to the upper right corner of the window viewport that allows searching through the current thumbnails for specific posts. Fade: Fade all posts that don't match in the thumbnail listing. Remove: Remove all posts that don't match from the thumbnail listing. DirectionsPlease read the \"thumbnail matching rules\" section under the help tab for information about creating searches.
The search starts minimized in the upper right corner. Left clicking the main icon will open and close the search. Right clicking the main icon will completely reset the search. Holding down shift while left clicking the main icon will toggle an active search's pinned status. Holding down control while left clicking the main icon will toggle an active search's negated status.
While open, the search can be entered/updated in the search box and the pinned status can be toggled by clicking the pushpin icon. Clicking the negative icon next to the pushpin icon will tell quick search to negate/invert the search being submitted. If no changes are made to an active search, submitting it a second time will reset the quick search. NotesOptions labeled with \"pinned\" will make searches default to being pinned.
A pinned search will persist across other pages in the same browsing session for that tab until it ends or the search is unpinned.
When not set to disabled, the quick search can be opened by using the \"F\" hotkey. Additionally, an active search can be reset by using \"Shift + F\". Pressing \"Escape\" while the quick search is open will close it.", {txtOptions:["Disabled:disabled", "Fade:fade", "Fade (Pinned):fade pinned", "Remove:remove", "Remove (Pinned):remove pinned"]}),
remove_tag_headers: newOption("checkbox", false, "Remove Tag Headers", "Remove the \"copyrights\", \"characters\", and \"artist\" headers from the sidebar tag list."),
resize_link_style: newOption("dropdown", "full", "Resize Link Style", "Set how the resize links in the post sidebar options section will display. Full: Show the \"resize to window\", \"resize to window width\", and \"resize to window height\" links on separate lines. Minimal: Show the \"resize to window\" (W&H), \"resize to window width\" (W), and \"resize to window height\" (H) links on one line.", {txtOptions:["Full:full", "Minimal:minimal"]}),
search_add: newOption("dropdown", "disabled", "Search Add", "Modify the sidebar tag list by adding, removing, or replacing links in the sidebar tag list that modify the current search's tags. Remove: Remove any preexisting \"+\" and \"–\" links. Link: Add \"+\" and \"–\" links to modified versions of the current search that include or exclude their respective tags. Toggle: Add toggle links that modify the search box with their respective tags. Clicking a toggle link will switch between a tag being included (+), excluded (–), potentially included among other tags (~), and removed (»). Right clicking a toggle link will immediately remove its tag. If a tag already exists in the search box or gets entered/removed through alternative means, the toggle link will automatically update to reflect the tag's current status. NoteThe remove option is intended for users above the basic user level that want to remove the links. For users that can't normally see the links and do not wish to see them, this setting should be set to disabled.", {txtOptions:["Disabled:disabled", "Remove:remove", "Link:link", "Toggle:toggle"]}),
@@ -773,14 +790,14 @@ function bbbScript() { // Wrapper for injecting the script into the document.
bbbNotice("Error retrieving post information. Your Danbooru API access is currently throttled. Please try again later.", -1);
bbbStatus("posts", "error");
}
- else if (xmlhttp.status !== 0) {
- if (xmlRetries < 1) {
+ else if (!bbb.flags.unloading) {
+ if (xmlhttp.status !== 0 && xmlRetries < 1) {
xmlRetries++;
fetchJSON(url, mode, optArg, xmlSession, xmlRetries);
}
else {
var linkId = uniqueIdNum(); // Create a unique ID.
- var noticeMsg = bbbNotice('Error retrieving post information (JSON Code: ' + xmlhttp.status + ' ' + xmlhttp.statusText + '). (Retry)', -1);
+ var noticeMsg = bbbNotice('Error retrieving post information (JSON Code: ' + xmlhttp.status + ' ' + xmlhttp.statusText + '). ' + (xmlhttp.status === 0 ? 'The connection was unexpectedly cancelled or timed out. ' : '') + '(Retry)', -1);
bbbStatus("posts", "error");
@@ -798,6 +815,7 @@ function bbbScript() { // Wrapper for injecting the script into the document.
}
};
xmlhttp.open("GET", url, true);
+ xmlhttp.timeout = 120000;
xmlhttp.send(null);
}
}
@@ -928,7 +946,7 @@ function bbbScript() { // Wrapper for injecting the script into the document.
newUrl = postInfo.file_img_src;
}
- imgContainer.innerHTML = '
';
+ imgContainer.innerHTML = ' ';
bbb.el.bbbLoader = document.getElementById("bbb-loader");
@@ -1020,7 +1038,7 @@ function bbbScript() { // Wrapper for injecting the script into the document.
// Create the new post.
var childSpan = document.createElement("span");
- childSpan.innerHTML = '
';
// Prepare thumbnails.
prepThumbnails(childSpan);
@@ -1285,8 +1303,8 @@ function bbbScript() { // Wrapper for injecting the script into the document.
else if (mode === "account_check")
accountUpdateHandler(docEl);
}
- else if (xmlhttp.status !== 0) {
- if (xmlRetries < 1) {
+ else if (!bbb.flags.unloading) {
+ if (xmlhttp.status !== 0 && xmlRetries < 1) {
xmlRetries++;
fetchPages(url, mode, optArg, xmlSession, xmlRetries);
}
@@ -1307,7 +1325,7 @@ function bbbScript() { // Wrapper for injecting the script into the document.
else if (mode === "account_check")
msg = "Error checking account settings";
- var noticeMsg = bbbNotice(msg + ' (HTML Code: ' + xmlhttp.status + ' ' + xmlhttp.statusText + '). (Retry)', -1);
+ var noticeMsg = bbbNotice(msg + ' (HTML Code: ' + xmlhttp.status + ' ' + xmlhttp.statusText + '). ' + (xmlhttp.status === 0 ? 'The connection was unexpectedly cancelled or timed out. ' : '') + '(Retry)', -1);
document.getElementById(linkId).addEventListener("click", function(event) {
if (event.button !== 0)
@@ -1322,6 +1340,7 @@ function bbbScript() { // Wrapper for injecting the script into the document.
}
};
xmlhttp.open("GET", url, true);
+ xmlhttp.timeout = 120000;
xmlhttp.send(null);
}
}
@@ -2032,7 +2051,7 @@ function bbbScript() { // Wrapper for injecting the script into the document.
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. Note that this tag will only work if you have a moderator level account or higher.
userid:1 - Match posts made by the user with an ID number of 1.
taggerid:1 - Match posts mostly tagged by the user with an ID number of 1.
approverid:1 - Match posts approved by the user with an ID number of 1. Accepted values include numbers, "any" for all posts with an approver, and "none" for posts without an approver.
source:http://www.4chan.org/ - Match posts with a source starting with http://www.4chan.org/. Accepted values include "any" for all posts with sources, "none" for all posts without sources, wildcard searches such as "*pixiv.net*" for posts with sources that contain pixiv.net, and non-wildcard searches that start matching at the beginning of a source.
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('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.
Shift + E - Continue loading more pages after pausing during 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();
@@ -3388,6 +3407,7 @@ function bbbScript() { // Wrapper for injecting the script into the document.
case "8.0.1":
case "8.0.2":
case "8.1":
+ case "8.2":
break;
}
@@ -3887,13 +3907,12 @@ function bbbScript() { // Wrapper for injecting the script into the document.
if (optionsSection) {
var optionItems = optionsSection.getElementsByTagName("li");
var downloadRegex = /^\s*Download\s*$/i;
- var downloadName = (getMeta("og:title") || "").replace(" - Danbooru", " - ");
for (i = 0, il = optionItems.length; i < il; i++) {
var optionItem = optionItems[i];
if (downloadRegex.test(optionItem.textContent)) {
- optionItem.innerHTML = 'Download';
+ optionItem.innerHTML = 'Download';
break;
}
}
@@ -4706,13 +4725,18 @@ function bbbScript() { // Wrapper for injecting the script into the document.
// Cycle through each post and apply titles and borders.
for (i = 0, il = posts.length; i < il; i++) {
var post = posts[i];
+ var postSibling = post.nextSibling;
var img = post.getElementsByTagName("img")[0];
+ // Clean out text nodes between thumbnail articles.
+ if (postSibling && postSibling.nodeType === 3)
+ postSibling.parentNode.removeChild(postSibling);
+
if (!img)
continue;
var postInfo = post.bbbInfo();
- var link = img.parentNode;
+ var link = img.bbbParent("A", 3);
var tagsStr = postInfo.tag_string || "";
var userStr = (postInfo.uploader_name ? " user:" + postInfo.uploader_name : "");
var ratingStr = (postInfo.rating ? " rating:" + postInfo.rating : "");
@@ -4812,7 +4836,7 @@ function bbbScript() { // Wrapper for injecting the script into the document.
function createThumbHTML(postInfo, query) {
// Create a thumbnail HTML string.
- return '';
+ return '';
}
function createThumb(postInfo, query) {
@@ -5309,6 +5333,18 @@ function bbbScript() { // Wrapper for injecting the script into the document.
loadButtonDiv.id = "bbb-endless-load-div";
buttonDiv.appendChild(loadButtonDiv);
+ var loadToggle = function() {
+ // Continue page loading after hitting the pause interval.
+ if (bbb.endless.paused !== true)
+ return;
+
+ bbb.el.endlessLoadButton.style.display = "none";
+ bbb.el.endlessLoadButton.blur();
+ bbb.endless.paused = false;
+ bbb.endless.append_page = true;
+ endlessCheck();
+ };
+
var loadButton = bbb.el.endlessLoadButton = document.createElement("a");
loadButton.innerHTML = "Load More";
loadButton.href = "#";
@@ -5318,11 +5354,7 @@ function bbbScript() { // Wrapper for injecting the script into the document.
if (event.button !== 0)
return;
- loadButton.style.display = "none";
- loadButton.blur();
- bbb.endless.paused = false;
- bbb.endless.append_page = true;
- endlessCheck();
+ loadToggle();
event.preventDefault();
}, false);
loadButtonDiv.appendChild(loadButton);
@@ -5348,8 +5380,9 @@ function bbbScript() { // Wrapper for injecting the script into the document.
paginatorParent.insertBefore(buttonDiv, paginator);
- // Create the hotkey.
+ // Create the hotkeys.
createHotkey("69", endlessToggle); // E
+ createHotkey("s69", loadToggle); // Shift + E
// Check the session default or original default value to see if endless pages should be enabled.
var sessionDefault = sessionStorage.getItem("bbb_endless_default");
@@ -6152,7 +6185,7 @@ function bbbScript() { // Wrapper for injecting the script into the document.
function blacklistSmartView(el) {
// Set up the smart view event listeners.
var img = el.getElementsByTagName("img")[0];
- var link = (img ? img.parentNode : undefined);
+ var link = (img ? img.bbbParent("A", 3) : undefined);
if (!link)
return;
@@ -6289,6 +6322,9 @@ function bbbScript() { // Wrapper for injecting the script into the document.
// Cache any necessary info before leaving the page.
window.addEventListener("beforeunload", saveStateCache);
+
+ // Flag if the page is being unloaded in order to differentiate it from other potential XML interruptions.
+ window.addEventListener("beforeunload", function(){ bbb.flags.unloading = true; });
}
function formatInfo(postInfo) {
@@ -6321,6 +6357,7 @@ function bbbScript() { // Wrapper for injecting the script into the document.
postInfo.uploader_name = (isModLevel() ? postInfo.uploader_name : "");
// Custom BBB properties.
+ postInfo.tag_string_desc = tagStringDesc(postInfo);
postInfo.file_url_desc = postFileUrlDesc(postInfo);
postInfo.thumb_class = postClasses(postInfo);
postFileSrcs(postInfo);
@@ -6346,9 +6383,11 @@ function bbbScript() { // Wrapper for injecting the script into the document.
delete postInfo.has_sound;
delete postInfo.flags;
delete postInfo.thumb_class;
+ delete postInfo.crop_img_src;
delete postInfo.preview_img_src;
delete postInfo.file_img_src;
delete postInfo.large_file_img_src;
+ delete postInfo.tag_string_desc;
delete postInfo.normalized_source;
return postInfo;
@@ -6418,26 +6457,33 @@ function bbbScript() { // Wrapper for injecting the script into the document.
function tagStringDesc(postInfo) {
// Create a Danbooru style post description.
- if (typeof(postInfo.tag_string_artist) !== "string")
- return "";
+ var downloadName = (getMeta("og:title") || "").replace(" - Danbooru", "");
+ var desc;
- var artists = tagStringList(postInfo.tag_string_artist.replace(/(?:^|\s)banned_artist(?:$|\s)/, " "));
- var characters = tagStringList(postInfo.tag_string_character.replace(/_\([^)]+\)(?:$|\s)/g, ""));
- var copyrights = tagStringList(postInfo.tag_string_copyright);
+ if (gLoc === "post" && downloadName)
+ desc = downloadName;
+ else if (typeof(postInfo.tag_string_artist) === "string") {
+ var artists = tagStringList(postInfo.tag_string_artist.replace(/(?:^|\s)banned_artist(?:$|\s)/, " "));
+ var characters = tagStringList(postInfo.tag_string_character.replace(/_\([^)]+\)($|\s)/g, "$1"));
+ var copyrights = tagStringList(postInfo.tag_string_copyright);
- if (characters !== "" && copyrights !== "")
- copyrights = " (" + copyrights + ")";
+ if (characters !== "" && copyrights !== "")
+ copyrights = " (" + copyrights + ")";
- if (artists !== "")
- artists = " drawn by " + artists;
+ if (artists !== "")
+ artists = " drawn by " + artists;
- return (characters + copyrights + artists).bbbSpaceClean() || "#" + postInfo.id;
+ desc = (characters + copyrights + artists).bbbSpaceClean() || "#" + postInfo.id;
+ }
+ else
+ desc = "";
+
+ return desc;
}
function tagStringFileUrlDesc(postInfo) {
// Create a Danbooru style post file/download description.
- var desc = tagStringDesc(postInfo);
- var fileDesc = (desc ? "__" + desc.replace(/[^0-9a-z]+/g, "_").replace(/^_+|_+$/g, "") + "__" : "");
+ var fileDesc = (postInfo.tag_string_desc ? "__" + postInfo.tag_string_desc.replace(/[^0-9a-z]+/g, "_").replace(/^_+|_+$/g, "") + "__" : "");
return fileDesc;
}
@@ -6458,6 +6504,14 @@ function bbbScript() { // Wrapper for injecting the script into the document.
// Add the BBB file URL properties to post info.
postInfo.preview_img_src = postInfo.preview_file_url || bbbHiddenImg;
+ if (postInfo.md5) {
+ var pathChars = postInfo.md5.match(/^(..)(..)/);
+
+ postInfo.crop_img_src = "https://raikou3.donmai.us/crop/" + pathChars[1] + "/" + pathChars[2] + "/" + postInfo.md5 + ".jpg";
+ }
+ else
+ postInfo.crop_img_src = bbbHiddenImg;
+
if (disable_tagged_filenames && postInfo.file_url.indexOf("__") > -1) {
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, "");
@@ -6613,7 +6667,7 @@ function bbbScript() { // Wrapper for injecting the script into the document.
var thumb = document.createElement("a");
thumb.href = "/posts/" + postInfo.id;
- thumb.innerHTML = '';
+ thumb.innerHTML = '';
if (before)
preview.insertBefore(thumb, before);
@@ -7926,6 +7980,8 @@ function bbbScript() { // Wrapper for injecting the script into the document.
'.bbb-quick-search-pinned #bbb-quick-search-pin, .bbb-quick-search-active.bbb-quick-search-pinned #bbb-quick-search-status {background-position: -144px -144px;}' + // Vertical pin.
'#bbb-quick-search-negate {background-position: -48px -129px;}' + // Negative sign.
'.bbb-quick-search-negated #bbb-quick-search-negate {background-position: -15px -192px;}' + // Negative sign in a dark circle.
+ '#bbb-quick-search.bbb-quick-search-negated {filter: invert(0.75);}' +
+ '#bbb-quick-search.bbb-quick-search-negated.bbb-quick-search-show {filter: invert(0);}' +
'#bbb-quick-search.bbb-quick-search-active {background-color: #DDDDDD;}' +
'#bbb-quick-search.bbb-quick-search-active.bbb-quick-search-show {background-color: #FFFFFF;}' +
'#bbb-quick-search-pin:focus, #bbb-quick-search-pin:hover, #bbb-quick-search-negate:focus, #bbb-quick-search-negate:hover {background-color: #CCCCCC;}' +
@@ -8109,24 +8165,7 @@ function bbbScript() { // Wrapper for injecting the script into the document.
// Make the submit event search posts or reset the search.
searchForm.addEventListener("submit", function(event) {
- var oldValue = bbb.quick_search.tags.bbbSpaceClean();
- var oldNegate = bbb.quick_search.negated;
- var curValue = searchInput.value.bbbSpaceClean();
- var curNegate = searchDiv.bbbHasClass("bbb-quick-search-negated");
-
- if (curValue === "" || (curValue === oldValue && curNegate === oldNegate))
- quickSearchReset();
- else {
- bbb.quick_search.tags = searchInput.value;
- bbb.quick_search.negated = searchDiv.bbbHasClass("bbb-quick-search-negated");
-
- if (searchDiv.bbbHasClass("bbb-quick-search-pinned"))
- sessionStorage.bbbSetItem("bbb_quick_search", JSON.stringify(bbb.quick_search));
- else if (quick_search.indexOf("pinned") > -1)
- quickSearchPinEnable();
-
- quickSearchTest();
- }
+ quickSearchToggle();
// Make autocomplete close without getting too tricky.
searchSubmit.focus();
@@ -8173,6 +8212,10 @@ function bbbScript() { // Wrapper for injecting the script into the document.
if (event.button === 0) {
if (event.shiftKey)
quickSearchPinToggle();
+ else if (event.ctrlKey) {
+ quickSearchNegateToggle();
+ quickSearchToggle();
+ }
else if (!searchDiv.bbbHasClass("bbb-quick-search-show"))
quickSearchOpen();
else
@@ -8237,6 +8280,30 @@ function bbbScript() { // Wrapper for injecting the script into the document.
createHotkey("s70", quickSearchReset); // SHIFT + F
}
+ function quickSearchToggle() {
+ // Submit the quick search or reset it if the current search is active.
+ var searchInput = bbb.el.quickSearchInput;
+ var searchDiv = bbb.el.quickSearchDiv;
+ var oldValue = bbb.quick_search.tags.bbbSpaceClean();
+ var oldNegate = bbb.quick_search.negated;
+ var curValue = searchInput.value.bbbSpaceClean();
+ var curNegate = searchDiv.bbbHasClass("bbb-quick-search-negated");
+
+ if (curValue === "" || (curValue === oldValue && curNegate === oldNegate))
+ quickSearchReset();
+ else {
+ bbb.quick_search.tags = searchInput.value;
+ bbb.quick_search.negated = searchDiv.bbbHasClass("bbb-quick-search-negated");
+
+ if (searchDiv.bbbHasClass("bbb-quick-search-pinned"))
+ sessionStorage.bbbSetItem("bbb_quick_search", JSON.stringify(bbb.quick_search));
+ else if (quick_search.indexOf("pinned") > -1)
+ quickSearchPinEnable();
+
+ quickSearchTest();
+ }
+ }
+
function quickSearchCheck() {
// Check the input value and adjust the submit button appearance accordingly.
var input = bbb.el.quickSearchInput;
@@ -8459,8 +8526,8 @@ function bbbScript() { // Wrapper for injecting the script into the document.
var targetTag = target.tagName;
var url; // If/else variable.
- if (targetTag === "IMG" && target.parentNode)
- url = target.parentNode.href;
+ if (targetTag === "IMG" && target.bbbParent("A", 3))
+ url = target.bbbParent("A", 3).href;
else if (targetTag === "A" && target.bbbHasClass("bbb-post-link", "bbb-thumb-link"))
url = target.href;
@@ -10211,7 +10278,7 @@ function bbbScript() { // Wrapper for injecting the script into the document.
$fields_multiple.autocomplete({
delay: 100,
- autoFocus: true,
+ autoFocus: false,
focus: function() { return false; },
select: function(event, ui) {
var before_caret_text = this.value.substring(0, this.selectionStart);
diff --git a/changelog.md b/changelog.md
index a2cd60a..6dbc272 100644
--- a/changelog.md
+++ b/changelog.md
@@ -1,5 +1,13 @@
Changelog
----------
+* Version 8.2.1:
+ * Added "Shift + E" as a hotkey for loading more pages when endless pages pauses.
+ * Added "Control + Left Click" on the quick search icon as a shortcut for negating the current search.
+ * Updated the error handling for requests from Danbooru in order to better support unexpected errors.
+ * Updated thumbnail formats and information in response to changes on Danbooru.
+ * Updated autocomplete to not automatically choose the first entry in response to changes on Danbooru.
+ * Updated the alternate text for thumbnails and posts in response to changes on Danbooru.
+ * Fixed character names containing copyright names in tagged filenames.
* Version 8.2:
* Added "userid", "taggerid", "approverid", and "source" to the script metatags.
* Updated the "user" metatag help text to clarify it can only be used by users at or above the moderator level.