From 22cc2bd4a848a0312fe3ff2fbae8ba4010eec722 Mon Sep 17 00:00:00 2001 From: Moebius-Strip Date: Thu, 10 Mar 2016 23:33:13 -0500 Subject: [PATCH 01/10] Disable DDL on filtered posts * Made the direct downloads for posts filtered out by the blacklist/quick search not show up in download managers. * Updated posts so that they use the post's tags for the "alt" and "title" attributes on the image. --- better-better-booru.user.js | 143 +++++++++++++++++++++++------------- 1 file changed, 91 insertions(+), 52 deletions(-) diff --git a/better-better-booru.user.js b/better-better-booru.user.js index 1aee66d..daf9ae9 100644 --- a/better-better-booru.user.js +++ b/better-better-booru.user.js @@ -297,7 +297,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. comment_score: newOption("checkbox", false, "Comment Scores", "Make comment scores visible by adding them as direct links to their respective comments."), custom_status_borders: newOption("checkbox", false, "Custom Status Borders", "Override Danbooru's thumbnail borders for deleted, flagged, pending, parent, and child images."), custom_tag_borders: newOption("checkbox", true, "Custom Tag Borders", "Add thumbnail borders to posts with specific tags."), - direct_downloads: newOption("checkbox", false, "Direct Downloads", "Allow download managers to download the posts displayed in the favorites, search, pool, popular, and favorite group listings."), + direct_downloads: newOption("checkbox", false, "Direct Downloads", "Allow download managers to download the posts displayed in the favorites, search, pool, popular, and favorite group listings. NotePosts filtered out by the blacklist or quick search will not provide direct downloads until the blacklist entry or quick search affecting them is disabled."), disable_embedded_notes: newOption("checkbox", false, "Disable Embedded Notes", "Force posts with embedded notes to display with the original note styling. NotesWhile notes will display with the original styling, the actual post settings will still have embedded notes set to enabled.

Due to the actual settings, users that may wish to edit notes will have to edit the notes with the embedded note styling so that nothing ends up breaking in unexpected ways. When toggling translation mode or opening the edit note dialog box, the notes will automatically revert back to the original embedded notes until the page is reloaded.

Note resizing and moving will be allowed without the reversion to embedded notes since this ability is sometimes necessary for badly positioned notes. Any note resizing or moving done as a part of intended note editing should be done after triggering the embedded note reversion since any changes before it will be lost."), 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, notes, 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.", {txtOptions:["Disabled:disabled", "Off:off", "On:on", "Paused:paused"]}), @@ -495,10 +495,6 @@ function bbbScript() { // This is needed to make this script work in Chrome. customCSS(); // Contains the portions related to notices. - delayMe(formatThumbnails); // Delayed to allow Danbooru to run first. - - delayMe(blacklistInit); // Delayed to allow Danbooru to run first. - thumbInfo(); removeTagHeaders(); @@ -517,12 +513,6 @@ function bbbScript() { // This is needed to make this script work in Chrome. autohideSidebar(); - delayMe(fixedSidebar); // Delayed to allow Danbooru layout to finalize. - - delayMe(collapseSidebar); // Delayed to allow Danbooru layout to finalize. - - delayMe(fixedPaginator); // Delayed to allow Danbooru layout to finalize. - moveSaveSearch(); pageCounter(); @@ -545,6 +535,16 @@ function bbbScript() { // This is needed to make this script work in Chrome. endlessInit(); + delayMe(formatThumbnails); // Delayed to allow Danbooru to run first. + + delayMe(blacklistInit); // Delayed to allow Danbooru to run first. + + delayMe(fixedSidebar); // Delayed to allow Danbooru layout to finalize. + + delayMe(collapseSidebar); // Delayed to allow Danbooru layout to finalize. + + delayMe(fixedPaginator); // Delayed to allow Danbooru layout to finalize. + /* Functions */ /* Functions for XML API info */ @@ -858,22 +858,19 @@ function bbbScript() { // This is needed to make this script work in Chrome. var newWidth = 0; var newHeight = 0; var newUrl = ""; - var altTxt = ""; if (load_sample_first && post.has_large) { newWidth = post.sample_width; newHeight = post.sample_height; newUrl = post.large_file_url; - altTxt = "Sample"; } else { newWidth = post.image_width; newHeight = post.image_height; newUrl = post.file_url; - altTxt = post.md5; } - imgContainer.innerHTML = '
' + altTxt + ' '; + imgContainer.innerHTML = '
' + post.tag_string + ' '; bbb.el.bbbLoader = document.getElementById("bbb-loader"); @@ -3820,7 +3817,6 @@ function bbbScript() { // This is needed to make this script work in Chrome. resizeLink.href = post.large_file_url; swapLink.innerHTML = "View sample"; swapLink.href = post.large_file_url; - img.alt = post.md5; img.setAttribute("height", post.image_height); img.setAttribute("width", post.image_width); bbbResizeNotice.style.display = (showResNot === "original" || showResNot === "all" ? "block" : "none"); @@ -3831,7 +3827,6 @@ function bbbScript() { // This is needed to make this script work in Chrome. resizeLink.href = post.file_url; swapLink.innerHTML = "View original"; swapLink.href = post.file_url; - img.alt = "Sample"; img.setAttribute("height", post.sample_height); img.setAttribute("width", post.sample_width); bbbResizeNotice.style.display = (showResNot === "sample" || showResNot === "all" ? "block" : "none"); @@ -4648,19 +4643,47 @@ function bbbScript() { // This is needed to make this script work in Chrome. var postId = post.getAttribute("data-id"); var ddlLink = post.getElementsByClassName("bbb-ddl")[0]; - if (!ddlLink) { // If the direct download doesn't already exist, create it. + // If the direct download doesn't already exist, create it. + if (!ddlLink) { ddlLink = document.createElement("a"); ddlLink.innerHTML = "Direct Download"; - ddlLink.href = postUrl || "DDL unavailable for post " + postId + ".jpg"; - ddlLink.id = "bbb-ddl-" + postId; ddlLink.className = "bbb-ddl"; post.appendChild(ddlLink); } - else if (ddlLink.href.indexOf("/data/") < 0) // Fix existing links for hidden thumbs. - ddlLink.href = postUrl || "DDL unavailable for post " + postId + ".jpg"; + + ddlLink.href = postUrl || "/data/DDL unavailable for post " + postId + ".jpg"; + + // Disable filtered posts. + if (post.bbbHasClass("blacklisted-active", "bbb-quick-search-filtered")) + unsetDDL(ddlLink); } } + function enablePostDDL(post) { + // Enable a post's DDL. + var ddlLink = post.getElementsByClassName("bbb-ddl")[0]; + + if (!direct_downloads || !ddlLink || post.bbbHasClass("blacklisted-active", "bbb-quick-search-filtered")) + return; + + ddlLink.href = ddlLink.href.replace("donmai.us/#data", "donmai.us/data"); + } + + function disablePostDDL(post) { + // Disable a post's DDL. + var ddlLink = post.getElementsByClassName("bbb-ddl")[0]; + + if (!direct_downloads || !ddlLink) + return; + + unsetDDL(ddlLink); + } + + function unsetDDL(ddlLink) { + // Disable a DDL URL with an anchor. + ddlLink.href = ddlLink.href.replace("donmai.us/data", "donmai.us/#data"); + } + function cleanLinks(target) { // Remove the query portion of thumbnail links. if (!clean_links) @@ -5294,8 +5317,13 @@ function bbbScript() { // This is needed to make this script work in Chrome. } // Reset any blacklisted thumbnails. - while (blacklistedPosts[0]) - blacklistedPosts[0].bbbRemoveClass("blacklisted blacklisted-active"); + var blacklistedPost = blacklistedPosts[0]; + + while (blacklistedPost) { + blacklistedPost.bbbRemoveClass("blacklisted blacklisted-active"); + enablePostDDL(blacklistedPost); + blacklistedPost = blacklistedPosts[0]; + } // Check if there actually are any tags. if (!blacklistTags || !/[^\s,]/.test(blacklistTags)) @@ -5455,7 +5483,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. els = document.getElementsByClassName(id); for (j = 0, jl = els.length; j < jl; j++) - els[j].bbbRemoveClass("blacklisted-active"); + blacklistShowPost(els[j]); } } } @@ -5482,7 +5510,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. els = document.getElementsByClassName(id); for (j = 0, jl = els.length; j < jl; j++) - els[j].bbbAddClass("blacklisted-active"); + blacklistHidePost(els[j]); } } } @@ -5534,19 +5562,16 @@ function bbbScript() { // This is needed to make this script work in Chrome. var id = el.id; var matchList = bbb.blacklist.match_list[id]; - if (typeof(matchList) === "undefined") { // Post hasn't been tested yet. + // Test posts that haven't been tested yet. + if (typeof(matchList) === "undefined") { matchList = bbb.blacklist.match_list[id] = {count: undefined, matches: [], override: undefined}; for (var i = 0, il = bbb.blacklist.entries.length; i < il; i++) { var entry = bbb.blacklist.entries[i]; if (thumbSearchMatch(el, entry.search)) { - el.bbbAddClass("blacklisted"); - - if (entry.active) { - el.bbbAddClass("blacklisted-active"); + if (entry.active) matchList.count = ++matchList.count || 1; - } else matchList.count = matchList.count || 0; @@ -5557,20 +5582,14 @@ function bbbScript() { // This is needed to make this script work in Chrome. if (matchList.count === undefined) // No match. matchList.count = false; - else if (el.id !== "image-container") { // Match found so prepare the thumbnail. - if (blacklist_thumb_controls) - blacklistPostControl(el, matchList); + } - if (blacklist_smart_view) - blacklistSmartView(el); - } + // Check the saved blacklist info for the post and change the thumbnail as needed. + if (matchList.count !== false && !el.bbbHasClass("blacklisted")) { + el.bbbAddClass("blacklisted"); - } - else if (matchList.count !== false && !el.bbbHasClass("blacklisted")) { // Post is already tested, but needs to be set up again. if (matchList.count > 0 && matchList.override !== true) - el.bbbAddClass("blacklisted blacklisted-active"); - else - el.bbbAddClass("blacklisted"); + blacklistHidePost(el); if (el.id !== "image-container") { if (blacklist_thumb_controls) @@ -5660,7 +5679,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. var els = document.getElementsByClassName(id); for (i = 0, il = els.length; i < il; i++) - els[i].bbbRemoveClass("blacklisted-active"); + blacklistShowPost(els[i]); blacklistHideTip(); bbb.blacklist.match_list[id].override = true; @@ -5683,7 +5702,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. var els = document.getElementsByClassName(id); for (var i = 0, il = els.length; i < il; i++) - els[i].bbbAddClass("blacklisted-active"); + blacklistHidePost(els[i]); bbb.blacklist.match_list[id].override = false; }, false); @@ -5784,6 +5803,18 @@ function bbbScript() { // This is needed to make this script work in Chrome. return true; } + function blacklistHidePost(post) { + // Hide blacklisted post content and adjust related content. + post.bbbAddClass("blacklisted-active"); + disablePostDDL(post); + } + + function blacklistShowPost(post) { + // Reveal blacklisted post content and adjust related content. + post.bbbRemoveClass("blacklisted-active"); + enablePostDDL(post); + } + /* Other functions */ function modifyDanbScript() { // Modify some Danbooru functions so that they don't run unnecessarily. @@ -7452,7 +7483,8 @@ function bbbScript() { // This is needed to make this script work in Chrome. function quickSearchReset() { // Completely reset the quick search. - var filtered = document.getElementsByClassName("bbb-quick-search-filtered"); + var filteredPosts = document.getElementsByClassName("bbb-quick-search-filtered"); + var filteredPost = filteredPosts[0]; bbb.quick_search = ""; bbb.el.quickSearchInput.value = ""; @@ -7461,8 +7493,11 @@ function bbbScript() { // This is needed to make this script work in Chrome. sessionStorage.removeItem("bbb_quick_search"); bbb.el.quickSearchDiv.bbbRemoveClass("bbb-quick-search-active bbb-quick-search-pinned"); - while (filtered[0]) - filtered[0].bbbRemoveClass("bbb-quick-search-filtered"); + while (filteredPost) { + filteredPost.bbbRemoveClass("bbb-quick-search-filtered"); + enablePostDDL(filteredPost); + filteredPost = filteredPosts[0]; + } } function quickSearchTest(target) { @@ -7482,10 +7517,14 @@ function bbbScript() { // This is needed to make this script work in Chrome. for (var i = 0, il = posts.length; i < il; i++) { var post = posts[i]; - if (!thumbSearchMatch(post, search)) + if (!thumbSearchMatch(post, search)) { post.bbbAddClass("bbb-quick-search-filtered"); - else + disablePostDDL(post); + } + else { post.bbbRemoveClass("bbb-quick-search-filtered"); + enablePostDDL(post); + } } } @@ -7503,7 +7542,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. // Toggle the quick search between pinned and not pinned for the session. var searchDiv = bbb.el.quickSearchDiv; - if (searchDiv.bbbHasClass("bbb-quick-search-show") || searchDiv.bbbHasClass("bbb-quick-search-active")) { + if (searchDiv.bbbHasClass("bbb-quick-search-show", "bbb-quick-search-active")) { if (!searchDiv.bbbHasClass("bbb-quick-search-pinned")) quickSearchPinEnable(); else @@ -9271,4 +9310,4 @@ function testBBBAccess() { runBBBScript(); } -testBBBAccess(); +testBBBAccess(); \ No newline at end of file From bc57ef12529eb05856dadd331f106a3554e676c7 Mon Sep 17 00:00:00 2001 From: Moebius-Strip Date: Mon, 14 Mar 2016 01:06:02 -0400 Subject: [PATCH 02/10] Mouse event & Disable embedded notes fixes * Fixed the translation mode hotkey breaking while using the "disable embedded notes" option. * Fixed the translation mode link responding to right click while using the "disable embedded notes" option. * Fixed the auto-hide sidebar retaining focus upon middle and right clicks. * Added a new prototype for simplifying the process of overriding Danbooru's click event listeners. * Added tests to most of the click events to prevent middle/right button problems. --- better-better-booru.user.js | 271 +++++++++++++++++++++++++++--------- 1 file changed, 206 insertions(+), 65 deletions(-) diff --git a/better-better-booru.user.js b/better-better-booru.user.js index daf9ae9..2d5e59b 100644 --- a/better-better-booru.user.js +++ b/better-better-booru.user.js @@ -133,6 +133,21 @@ function bbbScript() { // This is needed to make this script work in Chrome. this.addEventListener("DOMNodeInserted", func, false); }; + Element.prototype.bbbOverrideClick = function(func) { + // Override Danbooru's click event listeners by capturing clicks on the parent node and stopping them. + var target = this; + + var wrapperFunc = function(event) { + if (event.target !== target || event.button !== 0) + return; + + func(event); + event.stopPropagation(); + }; + + target.parentNode.addEventListener("click", wrapperFunc, true); + }; + Storage.prototype.bbbSetItem = function(key, value) { // Store a value in storage and warn if it is full. try { @@ -690,6 +705,9 @@ function bbbScript() { // This is needed to make this script work in Chrome. if (xmlhttp.status === 403 || xmlhttp.status === 401) { bbbNotice('Error retrieving post information. Access denied. You must be logged in to a Danbooru account to access the API for hidden image information and direct downloads.
(Do not warn me again and automatically bypass API features in the future.)', -1); document.getElementById("bbb-bypass-api-link").addEventListener("click", function(event) { + if (event.button !== 0) + return; + updateSettings("bypass_api", true); this.parentNode.innerHTML = "Settings updated. You may change this setting under the preferences tab in the settings panel."; event.preventDefault(); @@ -712,6 +730,9 @@ function bbbScript() { // This is needed to make this script work in Chrome. bbbStatus("posts", "error"); document.getElementById(linkId).addEventListener("click", function(event) { + if (event.button !== 0) + return; + closeBbbNoticeMsg(noticeMsg); searchJSON(mode, optArg); event.preventDefault(); @@ -1116,10 +1137,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. activeThumb.bbbAddClass("current-post"); // Make the show/hide links work. - newNotice.addEventListener("click", function(event) { - if (event.target !== previewLink) - return; - + previewLink.bbbOverrideClick(function(event) { if (thumbDiv.style.display === "block") { thumbDiv.style.display = "none"; previewLink.innerHTML = "show »"; @@ -1132,8 +1150,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. } event.preventDefault(); - event.stopPropagation(); - }, true); + }); // Prepare thumbnails. prepThumbnails(newNotice); @@ -1299,6 +1316,9 @@ function bbbScript() { // This is needed to make this script work in Chrome. var noticeMsg = bbbNotice(msg + ' (HTML Code: ' + xmlhttp.status + ' ' + xmlhttp.statusText + '). (Retry)', -1); document.getElementById(linkId).addEventListener("click", function(event) { + if (event.button !== 0) + return; + closeBbbNoticeMsg(noticeMsg); searchPages(mode, optArg); event.preventDefault(); @@ -1836,8 +1856,10 @@ function bbbScript() { // This is needed to make this script work in Chrome. link.href = "#"; link.innerHTML = "BBB Settings"; link.addEventListener("click", function(event) { - openMenu(); + if (event.button !== 0) + return; + openMenu(); event.preventDefault(); }, false); @@ -1882,6 +1904,9 @@ function bbbScript() { // This is needed to make this script work in Chrome. var tabBar = document.createElement("div"); tabBar.style.padding = "0px 15px"; tabBar.addEventListener("click", function(event) { + if (event.button !== 0) + return; + var target = event.target; if (target.href) @@ -1993,6 +2018,9 @@ function bbbScript() { // This is needed to make this script work in Chrome. close.className = "bbb-button"; close.style.marginRight = "15px"; close.addEventListener("click", function(event) { + if (event.button !== 0) + return; + removeMenu(); saveSettings(); event.preventDefault(); @@ -2003,6 +2031,9 @@ function bbbScript() { // This is needed to make this script work in Chrome. cancel.href = "#"; cancel.className = "bbb-button"; cancel.addEventListener("click", function(event) { + if (event.button !== 0) + return; + removeMenu(); loadSettings(); event.preventDefault(); @@ -2015,6 +2046,9 @@ function bbbScript() { // This is needed to make this script work in Chrome. reset.style.cssFloat = "right"; reset.style.color = "#ff1100"; reset.addEventListener("click", function(event) { + if (event.button !== 0) + return; + loadDefaults(); reloadMenu(); event.preventDefault(); @@ -2197,7 +2231,10 @@ function bbbScript() { // This is needed to make this script work in Chrome. item.name = settingName; item.type = "checkbox"; item.checked = userSetting; - item.addEventListener("click", function() { + item.addEventListener("click", function(event) { + if (event.button !== 0) + return; + bbb.user[settingName] = this.checked; bbb.settings.changed[settingName] = true; }, false); @@ -2220,6 +2257,9 @@ function bbbScript() { // This is needed to make this script work in Chrome. tagExpand.className = "bbb-edit-link"; tagExpand.innerHTML = "»"; tagExpand.addEventListener("click", function(event) { + if (event.button !== 0) + return; + tagEditWindow(item, bbb.user, settingName); event.preventDefault(); }, false); @@ -2282,7 +2322,10 @@ function bbbScript() { // This is needed to make this script work in Chrome. var enableBox = document.createElement("input"); enableBox.type = "checkbox"; enableBox.checked = borderItem.is_enabled; - enableBox.addEventListener("click", function() { borderItem.is_enabled = this.checked; }, false); + enableBox.addEventListener("click", function(event) { + if (event.button === 0) + borderItem.is_enabled = this.checked; + }, false); enableLabel.appendChild(enableBox); var editSpan = document.createElement("span"); @@ -2294,6 +2337,9 @@ function bbbScript() { // This is needed to make this script work in Chrome. moveButton.innerHTML = "Move"; moveButton.className = "bbb-border-button"; moveButton.addEventListener("click", function(event) { + if (event.button !== 0) + return; + moveBorder(borderSettings, indexWrapper); event.preventDefault(); }, false); @@ -2304,7 +2350,6 @@ function bbbScript() { // This is needed to make this script work in Chrome. previewButton.href = "#"; previewButton.innerHTML = "Preview"; previewButton.className = "bbb-border-button"; - previewButton.addEventListener("click", function(event) { event.preventDefault(); }, false); previewButton.bbbBorderPreview(borderItem); editSpan.appendChild(previewButton); @@ -2314,6 +2359,9 @@ function bbbScript() { // This is needed to make this script work in Chrome. deleteButton.innerHTML = "Delete"; deleteButton.className = "bbb-border-button"; deleteButton.addEventListener("click", function(event) { + if (event.button !== 0) + return; + deleteBorder(borderSettings, indexWrapper); event.preventDefault(); }, false); @@ -2324,6 +2372,9 @@ function bbbScript() { // This is needed to make this script work in Chrome. newButton.innerHTML = "New"; newButton.className = "bbb-border-button"; newButton.addEventListener("click", function(event) { + if (event.button !== 0) + return; + createBorder(borderSettings, indexWrapper); event.preventDefault(); }, false); @@ -2364,6 +2415,9 @@ function bbbScript() { // This is needed to make this script work in Chrome. nameExpand.className = "bbb-edit-link"; nameExpand.innerHTML = "»"; nameExpand.addEventListener("click", function(event) { + if (event.button !== 0) + return; + tagEditWindow(nameInput, borderItem, "tags"); event.preventDefault(); }, false); @@ -2472,6 +2526,9 @@ function bbbScript() { // This is needed to make this script work in Chrome. textBackup.className = "bbb-button"; textBackup.style.marginRight = "15px"; textBackup.addEventListener("click", function(event) { + if (event.button !== 0) + return; + createBackupText(); event.preventDefault(); }, false); @@ -2483,6 +2540,9 @@ function bbbScript() { // This is needed to make this script work in Chrome. pageBackup.className = "bbb-button"; pageBackup.style.marginRight = "15px"; pageBackup.addEventListener("click", function(event) { + if (event.button !== 0) + return; + createBackupPage(); event.preventDefault(); }, false); @@ -2498,6 +2558,9 @@ function bbbScript() { // This is needed to make this script work in Chrome. restoreBackup.href = "#"; restoreBackup.className = "bbb-button"; restoreBackup.addEventListener("click", function(event) { + if (event.button !== 0) + return; + restoreBackupText(); event.preventDefault(); }, false); @@ -2544,6 +2607,9 @@ function bbbScript() { // This is needed to make this script work in Chrome. formatButton.href = "#"; formatButton.className = "bbb-button"; formatButton.addEventListener("click", function(event) { + if (event.button !== 0) + return; + var textareaString = searchMultiToSingle(blacklistTextarea.value); blacklistTextarea.value = searchSingleToMulti(textareaString); @@ -2595,14 +2661,15 @@ function bbbScript() { // This is needed to make this script work in Chrome. } tocList.addEventListener("click", function (event) { - var target = event.target; - var targetValue = target.href; + var targetValue = event.target.href; - if (targetValue) { - var sectionTop = pageSections[targetValue.split("#")[1]].offsetTop; - bbb.el.menu.scrollDiv.scrollTop = sectionTop; - event.preventDefault(); - } + if (event.button !== 0 || !targetValue) + return; + + var sectionTop = pageSections[targetValue.split("#")[1]].offsetTop; + + bbb.el.menu.scrollDiv.scrollTop = sectionTop; + event.preventDefault(); }, false); return sectionFrag; @@ -2742,7 +2809,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. var target = event.target; var section = bbb.borderEdit.section; - if (target.className === "bbb-border-divider") { + if (target.className === "bbb-border-divider" && event.button === 0) { var newIndex = Number(target.parentNode.getAttribute("data-bbb-index")); var borderSettings = bbb.borderEdit.settings; @@ -2793,7 +2860,13 @@ function bbbScript() { // This is needed to make this script work in Chrome. } Element.prototype.bbbBorderPreview = function(borderItem) { - this.addEventListener("click", function(event) { showTip(event, "\"IMAGE\"", "background-color: #FFFFFF;"); }, false); + this.addEventListener("click", function(event) { + if (event.button !== 0) + return; + + showTip(event, "\"IMAGE\"", "background-color: #FFFFFF;"); + event.preventDefault(); + }, false); this.addEventListener("mouseout", hideTip, false); }; @@ -2801,6 +2874,9 @@ function bbbScript() { // This is needed to make this script work in Chrome. var tip = bbb.el.menu.tip; this.addEventListener("click", function(event) { + if (event.button !== 0) + return; + showTip(event, text, false); event.preventDefault(); }, false); @@ -3159,7 +3235,10 @@ function bbbScript() { // This is needed to make this script work in Chrome. var resizeLink = bbb.el.resizeLink = getId("bbb-resize-link", bbbResizeNotice); var closeResizeNotice = bbb.el.closeResizeNotice = getId("close-resize-notice", bbbResizeNotice); - closeResizeNotice.addEventListener("click", function() { + closeResizeNotice.addEventListener("click", function(event) { + if (event.button !== 0) + return; + var showResNot = bbb.user.show_resized_notice; bbbResizeNotice.style.display = "none"; @@ -3196,6 +3275,9 @@ function bbbScript() { // This is needed to make this script work in Chrome. swapListItem.appendChild(swapLink); swapLink.addEventListener("click", function(event) { + if (event.button !== 0) + return; + swapPost(); event.preventDefault(); }, false); @@ -3224,10 +3306,11 @@ function bbbScript() { // This is needed to make this script work in Chrome. var swapLink = bbb.el.swapLink; resizeLink.addEventListener("click", function(event) { - if (event.button === 0) { - swapPost(); - event.preventDefault(); - } + if (event.button !== 0) + return; + + swapPost(); + event.preventDefault(); }, false); bbbLoader.addEventListener("load", function() { // Change the image to the successfully loaded sample/original image. if (!bbb.post.swapped) @@ -3276,10 +3359,11 @@ function bbbScript() { // This is needed to make this script work in Chrome. var swapLink = bbb.el.swapLink; resizeLink.addEventListener("click", function(event) { - if (event.button === 0) { - swapPost(); - event.preventDefault(); - } + if (event.button !== 0) + return; + + swapPost(); + event.preventDefault(); }, false); img.addEventListener("error", function(event) { // State the image has failed loading and provide a link to the other image. if (img.src !== "about:blank") { @@ -3297,14 +3381,15 @@ function bbbScript() { // This is needed to make this script work in Chrome. function noteToggleInit() { // Override Danbooru's image click handler for toggling notes with a custom one. - document.addEventListener("click", function(event) { - if (event.target.id === "image" && event.button === 0) { - if (!bbb.post.translation_mode && !bbb.drag_scroll.moved) - Danbooru.Note.Box.toggle_all(); + var image = document.getElementById("image"); - event.stopPropagation(); - } - }, true); + if (!image) + return; + + image.bbbOverrideClick(function(event) { + if (!bbb.post.translation_mode && !bbb.drag_scroll.moved) + Danbooru.Note.Box.toggle_all(); + }); } function noteToggleLinkInit() { @@ -3324,6 +3409,9 @@ function bbbScript() { // This is needed to make this script work in Chrome. if (toggleLink) { document.getElementById("bbb-note-toggle").addEventListener("click", function(event) { + if (event.button !== 0) + return; + Danbooru.Note.Box.toggle_all(); event.preventDefault(); }, false); @@ -3339,7 +3427,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. var translateLink = document.getElementById("translate"); var toggleFunction; - if (post.file_ext !== "webm" && post.file_ext !== "mp4" && post.file_ext !== "swf") { // Don't allow translation functions on webm videos or flash. + if (post.file_ext !== "webm" && post.file_ext !== "mp4" && post.file_ext !== "swf") { // Don't allow translation functions on videos or flash. if (postTag !== "VIDEO") { // Make translation mode work on non-video content. // Allow the translation note functions if notes aren't locked. if (document.getElementById("note-locked-notice")) @@ -3348,20 +3436,16 @@ function bbbScript() { // This is needed to make this script work in Chrome. // Script translation mode events and tracking used to resolve timing issues. bbb.post.translation_mode = Danbooru.Note.TranslationMode.active; - // Override Danbooru's toggle function which may or may not exist depending on caching. + // Override Danbooru's toggle function. if (translateLink) { toggleFunction = function(event) { - if (event.target !== translateLink) - return; - Danbooru.Note.TranslationMode.toggle(event); translationModeToggle(); event.preventDefault(); - event.stopPropagation(); }; - translateLink.parentNode.addEventListener("click", toggleFunction, true); + translateLink.bbbOverrideClick(toggleFunction); } } else { // Allow note viewing on ugoira webm video samples, but don't allow editing. @@ -3374,13 +3458,13 @@ function bbbScript() { // This is needed to make this script work in Chrome. Danbooru.Note.Edit.show = toggleFunction; if (translateLink) - translateLink.addEventListener("click", toggleFunction, false); + translateLink.bbbOverrideClick(toggleFunction); // Override the hotkey for "N". createHotkey("78", toggleFunction); } } - else if (translateLink) { // If the translate link exists on videos or flash, provide a warning. + else { // Provide a warning for unsupported content. toggleFunction = function(event) { bbbNotice('Note editing is not allowed on flash/video content.', -1); event.preventDefault(); @@ -3388,7 +3472,10 @@ function bbbScript() { // This is needed to make this script work in Chrome. Danbooru.Note.TranslationMode.toggle = toggleFunction; Danbooru.Note.Edit.show = toggleFunction; - translateLink.addEventListener("click", toggleFunction, false); + + if (translateLink) + translateLink.bbbOverrideClick(toggleFunction); + createHotkey("78", toggleFunction); // Override the hotkey for "N". } } @@ -3415,14 +3502,14 @@ function bbbScript() { // This is needed to make this script work in Chrome. return; // Save the original note functions. - var origToggleFunction = bbb.hotkeys.post[78]; + var origToggleFunction = bbb.hotkeys.post[78].func; var origEditFunction = Danbooru.Note.Edit.show; // Create override functions. var toggleFunction = function(event) { var translateLink = document.getElementById("translate"); - if (event.type === "click" && event.target !== translateLink) + if (event.type === "click" && (event.target !== translateLink || event.button !== 0)) return; resetFunction(); @@ -3459,16 +3546,13 @@ function bbbScript() { // This is needed to make this script work in Chrome. function alternateImageSwap() { // Override Danbooru's image click handler for toggling notes with a custom one that swaps the image. var post = bbb.post.info; + var image = document.getElementById("image"); - if (post.has_large) { - document.addEventListener("click", function(event) { - if (event.target.id === "image" && event.button === 0) { - if (!bbb.post.translation_mode && !bbb.drag_scroll.moved) + if (post.has_large && image) { + image.bbbOverrideClick(function(event) { + if (!bbb.post.translation_mode && !bbb.drag_scroll.moved) swapPost(); - - event.stopPropagation(); - } - }, true); + }); } // Set up the "toggle notes" link since the image won't be used for toggling. @@ -3547,6 +3631,9 @@ function bbbScript() { // This is needed to make this script work in Chrome. var resizeLinkAll = bbb.el.resizeLinkAll = document.createElement("a"); resizeLinkAll.href = "#"; resizeLinkAll.addEventListener("click", function(event) { + if (event.button !== 0) + return; + resizePost("all"); event.preventDefault(); }, false); @@ -3554,6 +3641,9 @@ function bbbScript() { // This is needed to make this script work in Chrome. var resizeLinkWidth = bbb.el.resizeLinkWidth = document.createElement("a"); resizeLinkWidth.href = "#"; resizeLinkWidth.addEventListener("click", function(event) { + if (event.button !== 0) + return; + resizePost("width"); event.preventDefault(); }, false); @@ -3561,6 +3651,9 @@ function bbbScript() { // This is needed to make this script work in Chrome. var resizeLinkHeight = bbb.el.resizeLinkHeight = document.createElement("a"); resizeLinkHeight.href = "#"; resizeLinkHeight.addEventListener("click", function(event) { + if (event.button !== 0) + return; + resizePost("height"); event.preventDefault(); }, false); @@ -3595,6 +3688,9 @@ function bbbScript() { // This is needed to make this script work in Chrome. resizeLabelLink.innerHTML = "Resize:"; resizeLabelLink.style.marginRight = "2px"; resizeLabelLink.addEventListener("click", function(event) { + if (event.button !== 0) + return; + if (bbb.post.resize.mode === "none") resizePost("all"); else @@ -3893,6 +3989,9 @@ function bbbScript() { // This is needed to make this script work in Chrome. function requestRelations(event) { // Start the parent/child notice JSON request when the user chooses to display the thumbs in a notice. + if (event.button !== 0) + return; + var post = bbb.post.info; var target = event.target; @@ -4046,8 +4145,15 @@ function bbbScript() { // This is needed to make this script work in Chrome. function statusLinkEvents(link, notice) { // Attach events to the status links to enable a tooltip style notice. - link.addEventListener("click", function(event) { showStatusNotice(event, notice); }, false); - link.addEventListener("mouseout", function() { bbb.timers.minNotice = window.setTimeout(function() { notice.style.display = "none"; }, 200); }, false); + link.addEventListener("click", function(event) { + if (event.button === 0) + showStatusNotice(event, notice); + }, false); + link.addEventListener("mouseout", function() { + bbb.timers.minNotice = window.setTimeout(function() { + notice.style.display = "none"; + }, 200); + }, false); notice.addEventListener("mouseover", function() { window.clearTimeout(bbb.timers.minNotice); }, false); notice.addEventListener("mouseleave", function() { notice.style.display = "none"; }, false); } @@ -4090,7 +4196,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. // Disable click behavior when dragging the video around. if (targetTag === "VIDEO") { - document.addEventListener("click", function(event) { + target.parentNode.addEventListener("click", function(event) { if (event.button === 0 && event.target.id === "image" && bbb.drag_scroll.moved) event.preventDefault(); }, true); @@ -4863,6 +4969,9 @@ function bbbScript() { // This is needed to make this script work in Chrome. link.href = "#"; link.innerHTML = "Endless"; link.addEventListener("click", function(event) { + if (event.button !== 0) + return; + endlessToggle(); event.preventDefault(); }, false); @@ -4901,6 +5010,9 @@ function bbbScript() { // This is needed to make this script work in Chrome. loadButton.id = "bbb-endless-load-button"; loadButton.style.display = "none"; loadButton.addEventListener("click", function(event) { + if (event.button !== 0) + return; + loadButton.style.display = "none"; loadButton.blur(); bbb.endless.paused = false; @@ -4920,6 +5032,9 @@ function bbbScript() { // This is needed to make this script work in Chrome. enableButton.href = "#"; enableButton.id = "bbb-endless-enable-button"; enableButton.addEventListener("click", function(event) { + if (event.button !== 0) + return; + enableButton.blur(); endlessToggle(); event.preventDefault(); @@ -5995,6 +6110,9 @@ function bbbScript() { // This is needed to make this script work in Chrome. noticeMsg = bbb.el.noticeMsg = getId("bbb-notice-msg", notice); getId("bbb-notice-close", notice).addEventListener("click", function(event) { + if (event.button !== 0) + return; + closeBbbNotice(); event.preventDefault(); }, false); @@ -6209,6 +6327,12 @@ function bbbScript() { // This is needed to make this script work in Chrome. if (cancelButton) buttonDiv.appendChild(cancelButton); + + // Only allow left clicks to trigger the prompt buttons. + buttonDiv.addEventListener("click", function(event) { + if (event.button !== 0) + event.stopPropagation(); + }, true); } if (typeof(content) === "string") @@ -6699,10 +6823,11 @@ function bbbScript() { // This is needed to make this script work in Chrome. link.href = "/posts?new_posts=redirect&page=b1"; link.innerHTML = "New"; link.addEventListener("click", function(event) { - if (event.button === 0) { - trackNewLoad(); - event.preventDefault(); - } + if (event.button !== 0) + return; + + trackNewLoad(); + event.preventDefault(); }, false); var item = document.createElement("li"); @@ -6766,6 +6891,9 @@ function bbbScript() { // This is needed to make this script work in Chrome. postSections.appendChild(markSection); markLink.addEventListener("click", function(event) { + if (event.button !== 0) + return; + trackNewMark(); event.preventDefault(); }, false); @@ -6781,6 +6909,9 @@ function bbbScript() { // This is needed to make this script work in Chrome. postSections.appendChild(resetSection); resetLink.addEventListener("click", function(event) { + if (event.button !== 0) + return; + trackNewReset(); event.preventDefault(); }, false); @@ -8064,7 +8195,13 @@ function bbbScript() { // This is needed to make this script work in Chrome. sidebar.addEventListener("click", function(event) { var target = event.target; - if (target.id !== "tags") + if (event.button === 0 && target.id !== "tags") + target.blur(); + }, false); + sidebar.addEventListener("mouseup", function(event) { + var target = event.target; + + if (event.button !== 0 && target.id !== "tags") target.blur(); }, false); sidebar.addEventListener("focus", function() { @@ -8803,10 +8940,11 @@ function bbbScript() { // This is needed to make this script work in Chrome. var angleQuotes = String.fromCharCode(187); var enDash = String.fromCharCode(8211); + if ((type === "mouseup" && button !== 2) || (type === "click" && button !== 0)) // Don't respond to middle click and filter out duplicate user actions. + return; + if (button === 2) // Immediately remove the tag upon a right click. linkType = "~"; - else if (button !== 0 || (type === "mouseup" && button !== 2) || (type === "click" && button !== 0)) - return; // Each case changes the tag's toggle link display and updates the search box. switch (linkType) { @@ -8880,6 +9018,9 @@ function bbbScript() { // This is needed to make this script work in Chrome. content.appendChild(domainDiv); var cbFunc = function(event) { + if (event.button !== 0) + return; + var target = event.target; target.nextSibling.style.textDecoration = (target.checked ? "none" : "line-through"); From ea83108f4cd3d5d7da77a303564455d5eb31078e Mon Sep 17 00:00:00 2001 From: Moebius-Strip Date: Wed, 16 Mar 2016 00:29:26 -0400 Subject: [PATCH 03/10] Remove image title attribute * Updated to reflect Danbooru's reversion. --- 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 2d5e59b..ff8dec5 100644 --- a/better-better-booru.user.js +++ b/better-better-booru.user.js @@ -891,7 +891,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. newUrl = post.file_url; } - imgContainer.innerHTML = '
' + post.tag_string + ' '; + imgContainer.innerHTML = '
' + post.tag_string + ' '; bbb.el.bbbLoader = document.getElementById("bbb-loader"); From 2c93e27317304eba2e4ca977ce3514296b66aa33 Mon Sep 17 00:00:00 2001 From: Moebius-Strip Date: Tue, 22 Mar 2016 23:18:52 -0400 Subject: [PATCH 04/10] Help text clarification --- 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 ff8dec5..9666f21 100644 --- a/better-better-booru.user.js +++ b/better-better-booru.user.js @@ -2007,7 +2007,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. 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 coupled with percent signs:
  • (% ~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.
  • 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 not in an any active pools.
  • 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 coupled with percent signs:
  • (% ~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.
  • 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 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 d26d8a25a833294a90ad271980a753643912af5b Mon Sep 17 00:00:00 2001 From: Moebius-Strip Date: Wed, 23 Mar 2016 19:18:53 -0400 Subject: [PATCH 05/10] Help text clarification MK II --- 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 9666f21..dfb5ef2 100644 --- a/better-better-booru.user.js +++ b/better-better-booru.user.js @@ -2007,7 +2007,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. 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 coupled with percent signs:
  • (% ~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.
  • 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 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 coupled with percent signs:
  • (% ~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.
  • 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 65b6bb478380ae793d04ae28986b45bb34cfca69 Mon Sep 17 00:00:00 2001 From: Moebius-Strip Date: Wed, 30 Mar 2016 22:36:15 -0400 Subject: [PATCH 06/10] Help text clarification MK III --- 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 dfb5ef2..3534e6c 100644 --- a/better-better-booru.user.js +++ b/better-better-booru.user.js @@ -2622,7 +2622,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. helpButton.href = "#"; helpButton.className = "bbb-button"; helpButton.style.cssFloat = "right"; - helpButton.bbbSetTip("Hide posts that match the specified tag(s).DirectionsPlease read the \"thumbnail matching rules\" section under the help tab for information about creating matching rules for posts you wish to blacklist. Blank lines will be ignored and are only used for improved readability.

All commas will be converted to new lines and all extra spaces and extra blank lines will be removed the next time the settings are opened. By using the \"format\" button, you can manually perform this action on the blacklist rules. NoteWhen logged in, the account's \"blacklisted tags\" list will override this option. This behavior can be changed with the \"override blacklist\" option under the preferences tab."); + helpButton.bbbSetTip("Hide posts that match the specified tag(s).DirectionsPlease read the \"thumbnail matching rules\" section under the help tab for information about creating matching rules for posts you wish to blacklist. Blank lines will be ignored and are only used for improved readability.

All commas outside of tag groups will be converted to new lines and all extra spaces and extra blank lines will be removed the next time the settings are opened. By using the \"format\" button, you can manually perform this action on the blacklist rules. NoteWhen logged in, the account's \"blacklisted tags\" list will override this option. This behavior can be changed with the \"override blacklist\" option under the preferences tab."); buttonDiv.appendChild(helpButton); return sectionFrag; From 7c48acf827124ca8c271ac6624d28f57a85055c9 Mon Sep 17 00:00:00 2001 From: Moebius-Strip Date: Sat, 2 Apr 2016 23:31:38 -0400 Subject: [PATCH 07/10] Replace remaining XPath * Replaced all XPath with the cleaner and faster querySelector method. --- better-better-booru.user.js | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/better-better-booru.user.js b/better-better-booru.user.js index 3534e6c..5781730 100644 --- a/better-better-booru.user.js +++ b/better-better-booru.user.js @@ -1531,7 +1531,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. var postEl = postContent.el; var postTag = (postEl ? postEl.tagName : undefined); var dataInfo = [imgContainer.getAttribute("data-file-url"), imgContainer.getAttribute("data-md5"), imgContainer.getAttribute("data-file-ext")]; - var directLink = getId("image-resize-link", target) || document.evaluate('.//section[@id="post-information"]/ul/li/a[starts-with(@href, "/data/")]', target, null, 9, null).singleNodeValue; + var directLink = getId("image-resize-link", target) || target.querySelector("#post-information ul li a[href^='/data/']"); var twitterInfo = getMeta("twitter:image", target); var previewInfo = getMeta("og:image", target); var imgHeight = Number(imgContainer.getAttribute("data-height")); @@ -1658,7 +1658,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. var swfEmb = (swfObj ? swfObj.getElementsByTagName("embed")[0] : undefined); var video = imgContainer.getElementsByTagName("video")[0]; var ugoira = imgContainer.getElementsByTagName("canvas")[0]; - var other = document.evaluate('.//a[starts-with(@href, "/data/")]', imgContainer, null, 9, null).singleNodeValue; + var other = imgContainer.querySelector("a[href^='/data/']"); var el = swfEmb || video || ugoira || img || other; var secondaryEl = swfObj; // Other elements related to the main element. Only applies to flash for now. @@ -7342,36 +7342,41 @@ function bbbScript() { // This is needed to make this script work in Chrome. if (hide_comment_notice) { var commentGuide; + var commentGuideParent; if (gLoc === "post") { - commentGuide = document.evaluate('//section[@id="comments"]/h2/a[contains(@href,"/wiki_pages")]/..', document, null, 9, null).singleNodeValue; + commentGuide = document.querySelector("#comments h2 a[href*='howto']"); + commentGuideParent = (commentGuide ? commentGuide.parentNode : undefined); - if (commentGuide && commentGuide.textContent === "Before commenting, read the how to comment guide.") - commentGuide.style.display = "none"; + if (commentGuideParent && commentGuideParent.textContent === "Before commenting, read the how to comment guide.") + commentGuideParent.style.display = "none"; } else if (gLoc === "comments") { - commentGuide = document.evaluate('//div[@id="a-index"]/div/h2/a[contains(@href,"/wiki_pages")]/..', document, null, 9, null).singleNodeValue; + commentGuide = document.querySelector("#a-index div h2 a[href*='howto']"); + commentGuideParent = (commentGuide ? commentGuide.parentNode : undefined); - if (commentGuide && commentGuide.textContent === "Before commenting, read the how to comment guide.") - commentGuide.style.display = "none"; + if (commentGuideParent && commentGuideParent.textContent === "Before commenting, read the how to comment guide.") + commentGuideParent.style.display = "none"; } } if (hide_tag_notice && gLoc === "post") { - var tagGuide = document.evaluate('//section[@id="edit"]/div/p/a[contains(@href,"/howto:tag")]/..', document, null, 9, null).singleNodeValue; + var tagGuide = document.querySelector("#edit div p a[href*='howto']"); + var tagGuideParent = (tagGuide ? tagGuide.parentNode : undefined); - if (tagGuide && tagGuide.textContent === "Before editing, read the how to tag guide.") - tagGuide.style.display = "none"; + if (tagGuideParent && tagGuideParent.textContent === "Before editing, read the how to tag guide.") + tagGuideParent.style.display = "none"; } if (hide_upload_notice && gLoc === "upload") styles += '#upload-guide-notice {display: none !important;}'; if (hide_pool_notice && gLoc === "new_pool") { - var poolGuide = document.evaluate('//div[@id="c-new"]/p/a[contains(@href,"/howto:pools")]/..', document, null, 9, null).singleNodeValue; + var poolGuide = document.querySelector("#c-new p a[href*='howto']"); + var poolGuideParent = (poolGuide ? poolGuide.parentNode : undefined); - if (poolGuide && poolGuide.textContent === "Before creating a pool, read the pool guidelines.") - poolGuide.style.display = "none"; + if (poolGuideParent && poolGuideParent.textContent === "Before creating a pool, read the pool guidelines.") + poolGuideParent.style.display = "none"; } customStyles.innerHTML = styles; From ce38d70115b06161d80a7d2e705090c2912fa4de Mon Sep 17 00:00:00 2001 From: Moebius-Strip Date: Sun, 3 Apr 2016 22:42:16 -0400 Subject: [PATCH 08/10] Translation mode changes & fixes * Changed the way translation mode is altered by changing the start and stop functions instead of the toggle function. * Fixed drag scrolling being broken by the translation mode notice link for turning translation mode off. * Fixed the translation mode hotkey being available when it shouldn't be. --- better-better-booru.user.js | 70 +++++++++++++++---------------------- 1 file changed, 28 insertions(+), 42 deletions(-) diff --git a/better-better-booru.user.js b/better-better-booru.user.js index 5781730..c7535a4 100644 --- a/better-better-booru.user.js +++ b/better-better-booru.user.js @@ -275,10 +275,6 @@ function bbbScript() { // This is needed to make this script work in Chrome. 51: {func: resizeHotkey, custom_handler: true}, // 3 52: {func: resizeHotkey, custom_handler: true}, // 4 66: {func: openMenu}, // B - 78: {func: function(event) { // N - Danbooru.Note.TranslationMode.toggle(event); - translationModeToggle(); - }}, 86: {func: swapPost} // V } }, @@ -288,8 +284,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. mode: "none", ratio: 1 }, - swapped: false, // Whether the post content has been changed between the original and sample versions. - translation_mode: false + swapped: false // Whether the post content has been changed between the original and sample versions. }, options: { // Setting options and data. bbb_version: "7.2.3", @@ -3387,7 +3382,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. return; image.bbbOverrideClick(function(event) { - if (!bbb.post.translation_mode && !bbb.drag_scroll.moved) + if (!Danbooru.Note.TranslationMode.active && !bbb.drag_scroll.moved) Danbooru.Note.Box.toggle_all(); }); } @@ -3429,23 +3424,10 @@ function bbbScript() { // This is needed to make this script work in Chrome. if (post.file_ext !== "webm" && post.file_ext !== "mp4" && post.file_ext !== "swf") { // Don't allow translation functions on videos or flash. if (postTag !== "VIDEO") { // Make translation mode work on non-video content. - // Allow the translation note functions if notes aren't locked. - if (document.getElementById("note-locked-notice")) - return; - - // Script translation mode events and tracking used to resolve timing issues. - bbb.post.translation_mode = Danbooru.Note.TranslationMode.active; - - // Override Danbooru's toggle function. - if (translateLink) { - toggleFunction = function(event) { - Danbooru.Note.TranslationMode.toggle(event); - translationModeToggle(); - - event.preventDefault(); - }; - - translateLink.bbbOverrideClick(toggleFunction); + // Set up/override the translate link and hotkey if notes aren't locked. + if (!document.getElementById("note-locked-notice") && translateLink) { + translateLink.bbbOverrideClick(Danbooru.Note.TranslationMode.toggle); + createHotkey("78", Danbooru.Note.TranslationMode.toggle); } } else { // Allow note viewing on ugoira webm video samples, but don't allow editing. @@ -3454,14 +3436,13 @@ function bbbScript() { // This is needed to make this script work in Chrome. event.preventDefault(); }; - Danbooru.Note.TranslationMode.toggle = toggleFunction; + Danbooru.Note.TranslationMode.start = toggleFunction; Danbooru.Note.Edit.show = toggleFunction; if (translateLink) translateLink.bbbOverrideClick(toggleFunction); - // Override the hotkey for "N". - createHotkey("78", toggleFunction); + createHotkey("78", toggleFunction); // Override the hotkey for "N". } } else { // Provide a warning for unsupported content. @@ -3470,7 +3451,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. event.preventDefault(); }; - Danbooru.Note.TranslationMode.toggle = toggleFunction; + Danbooru.Note.TranslationMode.start = toggleFunction; Danbooru.Note.Edit.show = toggleFunction; if (translateLink) @@ -3502,7 +3483,6 @@ function bbbScript() { // This is needed to make this script work in Chrome. return; // Save the original note functions. - var origToggleFunction = bbb.hotkeys.post[78].func; var origEditFunction = Danbooru.Note.Edit.show; // Create override functions. @@ -3513,9 +3493,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. return; resetFunction(); - Danbooru.Note.TranslationMode.toggle(event); - translationModeToggle(); event.preventDefault(); event.stopPropagation(); @@ -3530,7 +3508,9 @@ function bbbScript() { // This is needed to make this script work in Chrome. // Remove all overrides/overwrites. Danbooru.Note.Edit.show = origEditFunction; document.removeEventListener("click", toggleFunction, true); - createHotkey("78", origToggleFunction); + + if (!document.getElementById("note-locked-notice")) + createHotkey("78", Danbooru.Note.TranslationMode.toggle); // Reset notes with embedded notes enabled. Danbooru.Note.embed = true; @@ -3550,7 +3530,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. if (post.has_large && image) { image.bbbOverrideClick(function(event) { - if (!bbb.post.translation_mode && !bbb.drag_scroll.moved) + if (!Danbooru.Note.TranslationMode.active && !bbb.drag_scroll.moved) swapPost(); }); } @@ -4191,9 +4171,22 @@ function bbbScript() { // This is needed to make this script work in Chrome. if (targetTag === "IMG" || targetTag === "VIDEO" || targetTag === "CANVAS") { bbb.drag_scroll.target = target; - if (!bbb.post.translation_mode) + if (!Danbooru.Note.TranslationMode.active) dragScrollEnable(); + var startFunction = Danbooru.Note.TranslationMode.start; + var stopFunction = Danbooru.Note.TranslationMode.stop; + + Danbooru.Note.TranslationMode.start = function(event) { + startFunction(event); + dragScrollToggle(); + }; + + Danbooru.Note.TranslationMode.stop = function(event) { + stopFunction(event); + dragScrollToggle(); + }; + // Disable click behavior when dragging the video around. if (targetTag === "VIDEO") { target.parentNode.addEventListener("click", function(event) { @@ -4209,7 +4202,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. if (!post_drag_scroll || !bbb.drag_scroll.target) return; - if (bbb.post.translation_mode) + if (Danbooru.Note.TranslationMode.active) dragScrollDisable(); else dragScrollEnable(); @@ -4270,13 +4263,6 @@ function bbbScript() { // This is needed to make this script work in Chrome. event.preventDefault(); } - function translationModeToggle() { - // Toggle the translation mode status and drag scrolling. - bbb.post.translation_mode = !bbb.post.translation_mode; - - dragScrollToggle(); - } - function autoscrollPost() { // Automatically scroll a post to the desired position. var scrolled = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0; From 3337bd67d8e23977f942c3b5ce640028f2b4f12d Mon Sep 17 00:00:00 2001 From: Moebius-Strip Date: Mon, 4 Apr 2016 13:55:48 -0400 Subject: [PATCH 09/10] Regex typo --- 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 c7535a4..1ac1eb3 100644 --- a/better-better-booru.user.js +++ b/better-better-booru.user.js @@ -7922,7 +7922,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. var activeTag = active.tagName; var activeType = active.type; - if (activeTag === "SELECT" || activeTag === "TEXTAREA" || (activeTag === "INPUT" && !/^(:?button|checkbox|file|hidden|image|radio|reset|submit)$/.test(activeType))) // Input types: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Attributes + if (activeTag === "SELECT" || activeTag === "TEXTAREA" || (activeTag === "INPUT" && !/^(?:button|checkbox|file|hidden|image|radio|reset|submit)$/.test(activeType))) // Input types: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Attributes return; var loc = (gLoc === "post" ? "post" : "other"); @@ -9442,4 +9442,4 @@ function testBBBAccess() { runBBBScript(); } -testBBBAccess(); \ No newline at end of file +testBBBAccess(); From 3a69bb00fb524f263330ef39925a0a604fdf967c Mon Sep 17 00:00:00 2001 From: Moebius-Strip Date: Fri, 15 Apr 2016 23:54:52 -0400 Subject: [PATCH 10/10] Version 7.2.4 --- better-better-booru.user.js | 5 +++-- changelog.md | 6 ++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/better-better-booru.user.js b/better-better-booru.user.js index 1ac1eb3..7f051c3 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. Including the viewing of hidden/censored images on non-upgraded accounts and more. -// @version 7.2.3 +// @version 7.2.4 // @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/* @@ -287,7 +287,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. swapped: false // Whether the post content has been changed between the original and sample versions. }, options: { // Setting options and data. - bbb_version: "7.2.3", + bbb_version: "7.2.4", 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."), arrow_nav: newOption("checkbox", false, "Arrow Navigation", "Allow the use of the left and right arrow keys to navigate pages. NoteThis option has no effect on individual posts."), 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"]}), @@ -3134,6 +3134,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. case "7.2": case "7.2.1": case "7.2.2": + case "7.2.3": break; } diff --git a/changelog.md b/changelog.md index 1adfcd9..25ecba0 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,11 @@ Changelog ---------- +* Version 7.2.4: + * Fixed the "direct downloads" option not excluding posts filtered out by the blacklist/quick search. + * Fixed the "post drag scrolling" option being broken by the translation mode notice link for turning translation mode off. + * Fixed the translation mode hotkey breaking while using the "disable embedded notes" option. + * Fixed the translation mode hotkey being available when it shouldn't be. + * Fixed various problems where middle and right click were causing unexpected and/or undesirable effects. * Version 7.2.3: * Fixed the retry link for retrieving hidden thumbnails. * Version 7.2.2: