From c0af87d617142f5b92cd43c65431927510cc7262 Mon Sep 17 00:00:00 2001 From: Moebius-Strip Date: Sat, 12 Sep 2015 12:16:32 -0400 Subject: [PATCH 01/27] Fix "ghost" video audio * Keeps the original video from continuing to play by pausing it, changing the source, and reloading it. --- better-better-booru.user.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/better-better-booru.user.js b/better-better-booru.user.js index ba6a058..93320b9 100644 --- a/better-better-booru.user.js +++ b/better-better-booru.user.js @@ -744,8 +744,18 @@ function bbbScript() { // This is needed to make this script work in Chrome. // Create content. if (post.file_ext === "swf") // Create flash object. imgContainer.innerHTML = '

Save this flash (right click and save)

'; - else if (post.file_ext === "webm" || post.file_ext === "mp4") // Create video + else if (post.file_ext === "webm" || post.file_ext === "mp4") { // Create video + var origVideo = imgContainer.getElementsByTagName("video")[0]; + + // Keep the original video from continuing to play after being removed. Why does it even do this...? + if (origVideo) { + origVideo.pause(); + origVideo.src = "about:blank"; + origVideo.load(); + } + imgContainer.innerHTML = '

Save this video (right click and save)

'; + } else if (post.file_ext === "zip" && /(?:^|\s)ugoira(?:$|\s)/.test(post.tag_string)) { // Create ugoira var useUgoiraOrig = getVar("original"); From 12c727ff1f45d58f180a3cac9bc1168dac3dbee1 Mon Sep 17 00:00:00 2001 From: Moebius-Strip Date: Sat, 12 Sep 2015 13:22:24 -0400 Subject: [PATCH 02/27] Fix icon overlay positioning * Moved the blacklist option's overlay adjustment steps into the default CSS. --- better-better-booru.user.js | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/better-better-booru.user.js b/better-better-booru.user.js index 93320b9..1d44da7 100644 --- a/better-better-booru.user.js +++ b/better-better-booru.user.js @@ -6694,8 +6694,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. '.post-preview div.preview {height: ' + thumbMaxHeight + 'px !important; width: ' + thumbMaxWidth + 'px !important; margin-right: ' + commentExtraSpace + 'px !important;}' + '.post-preview div.preview a.bbb-thumb-link {line-height: 0px !important;}' + '.post-preview a.bbb-thumb-link img {border-width: ' + border_width + 'px !important; padding: ' + border_spacing + 'px !important;}' + - 'a.bbb-thumb-link.bbb-custom-tag {border-width: ' + border_width + 'px !important;}' + - 'article.post-preview:before, .post-preview div.preview:before {margin: ' + totalBorderWidth + 'px !important;}'; // Thumbnail icon overlay position adjustment. + 'a.bbb-thumb-link.bbb-custom-tag {border-width: ' + border_width + 'px !important;}'; if (custom_status_borders) { var activeStatusStyles = ""; @@ -6768,6 +6767,22 @@ function bbbScript() { // This is needed to make this script work in Chrome. } } + // Overlay setup. + styles += 'article.post-preview:before, div.post.post-preview div.preview:before {content: none !important;}' + // Disable original Danbooru animated overlay. + 'article.post-preview[data-tags~="animated"] a.bbb-thumb-link:before, article.post-preview[data-file-ext="swf"] a.bbb-thumb-link:before, article.post-preview[data-file-ext="webm"] a.bbb-thumb-link:before, article.post-preview[data-file-ext="mp4"] a.bbb-thumb-link:before, div.post.post-preview[data-tags~="animated"] div.preview a.bbb-thumb-link:before, div.post.post-preview[data-file-ext="swf"] div.preview a.bbb-thumb-link:before, div.post.post-preview[data-file-ext="webm"] div.preview a.bbb-thumb-link:before, div.post.post-preview[data-file-ext="mp4"] div.preview a.bbb-thumb-link:before {content: "\\25BA"; position: absolute; width: 20px; height: 20px; color: #FFFFFF; background-color: rgba(0, 0, 0, 0.5); line-height: 20px; top: 0px; left: 0px;}' + // Recreate Danbooru animated overlay. + 'article.post-preview[data-has-sound="true"] a.bbb-thumb-link:before, div.post.post-preview[data-has-sound="true"] div.preview a.bbb-thumb-link:before {content: "\\266A"; position: absolute; width: 20px; height: 20px; color: #FFFFFF; background-color: rgba(0, 0, 0, 0.5); line-height: 20px; top: 0px; left: 0px;}' + // Recreate Danbooru audio overlay. + 'article.post-preview.blacklisted a.bbb-thumb-link:after, article.post-preview a.bbb-thumb-link:before, div.post.post-preview.blacklisted div.preview a.bbb-thumb-link:after, div.post.post-preview div.preview a.bbb-thumb-link:before {margin: ' + (border_width + border_spacing) + 'px;}' + // Margin applies to posts with no borders or only a status border. + 'article.post-preview.blacklisted a.bbb-thumb-link.bbb-custom-tag:after, article.post-preview a.bbb-thumb-link.bbb-custom-tag:before, div.post.post-preview.blacklisted div.preview a.bbb-thumb-link.bbb-custom-tag:after, div.post.post-preview div.preview a.bbb-thumb-link.bbb-custom-tag:before {margin: ' + border_spacing + 'px;}' + // Margin applies to posts with only a custom border. + 'article.post-preview.blacklisted.blacklisted-active a.bbb-thumb-link:after, article.post-preview.blacklisted.blacklisted-active a.bbb-thumb-link:before, div.post.post-preview.blacklisted.blacklisted-active div.preview a.bbb-thumb-link:after, div.post.post-preview.blacklisted.blacklisted-active div.preview a.bbb-thumb-link:before {content: none;}' + // Don't display when actively blacklisted. + 'article.post-preview a.bbb-thumb-link, div.post.post-preview div.preview a.bbb-thumb-link {position: relative;}'; // Allow the overlays to position relative to the link. + + for (i = 0; i < sbsl; i++) { + statusBorderItem = status_borders[i]; + + if (statusBorderItem.is_enabled) + styles += 'article.post-preview.' + statusBorderItem.class_name + ' a.bbb-thumb-link.bbb-custom-tag:after, article.post-preview.' + statusBorderItem.class_name + ' a.bbb-thumb-link.bbb-custom-tag:before, div.post.post-preview.' + statusBorderItem.class_name + ' div.preview a.bbb-thumb-link.bbb-custom-tag:after, div.post.post-preview.' + statusBorderItem.class_name + ' div.preview a.bbb-thumb-link.bbb-custom-tag:before {margin: ' + (border_width + border_spacing + customBorderSpacing) + 'px !important}'; // Margin applies to posts with a status and custom border. + } + // Thumbnail info. var thumbInfoStyle = "height: 18px; font-size: 14px; line-height: 18px; text-align: center;"; @@ -6848,21 +6863,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. // Blacklist marking. if (blacklist_thumb_mark === "icon") { - styles += 'article.post-preview:before, div.post.post-preview div.preview:before {content: none !important;}' + // Disable original Danbooru animated overlay. - 'article.post-preview.blacklisted a.bbb-thumb-link:after, div.post.post-preview.blacklisted div.preview a.bbb-thumb-link:after {content: "\\A0"; position: absolute; bottom: 0px; right: 0px; height: 20px; width: 20px; line-height: 20px; font-weight: bold; color: #FFFFFF; background: rgba(0, 0, 0, 0.5) url(\'' + bbbBlacklistIcon + '\');}' + // Create blacklist overlay. - 'article.post-preview[data-tags~="animated"] a.bbb-thumb-link:before, article.post-preview[data-file-ext="swf"] a.bbb-thumb-link:before, article.post-preview[data-file-ext="webm"] a.bbb-thumb-link:before, article.post-preview[data-file-ext="mp4"] a.bbb-thumb-link:before, div.post.post-preview[data-tags~="animated"] div.preview a.bbb-thumb-link:before, div.post.post-preview[data-file-ext="swf"] div.preview a.bbb-thumb-link:before, div.post.post-preview[data-file-ext="webm"] div.preview a.bbb-thumb-link:before, div.post.post-preview[data-file-ext="mp4"] div.preview a.bbb-thumb-link:before {content: "\\25BA"; position: absolute; width: 20px; height: 20px; color: #FFFFFF; background-color: rgba(0, 0, 0, 0.5); line-height: 20px; top: 0px; left: 0px;}' + // Recreate Danbooru animated overlay. - 'article.post-preview[data-has-sound="true"] a.bbb-thumb-link:before, div.post.post-preview[data-has-sound="true"] div.preview a.bbb-thumb-link:before {content: "\\266A"; position: absolute; width: 20px; height: 20px; color: #FFFFFF; background-color: rgba(0, 0, 0, 0.5); line-height: 20px; top: 0px; left: 0px;}' + // Recreate Danbooru audio overlay. - 'article.post-preview.blacklisted a.bbb-thumb-link:after, article.post-preview a.bbb-thumb-link:before, div.post.post-preview.blacklisted div.preview a.bbb-thumb-link:after, div.post.post-preview div.preview a.bbb-thumb-link:before {margin: ' + (border_width + border_spacing) + 'px;}' + // Margin applies to posts with no borders or only a status border. - 'article.post-preview.blacklisted a.bbb-thumb-link.bbb-custom-tag:after, article.post-preview a.bbb-thumb-link.bbb-custom-tag:before, div.post.post-preview.blacklisted div.preview a.bbb-thumb-link.bbb-custom-tag:after, div.post.post-preview div.preview a.bbb-thumb-link.bbb-custom-tag:before {margin: ' + border_spacing + 'px;}' + // Margin applies to posts with only a custom border. - 'article.post-preview.blacklisted.blacklisted-active a.bbb-thumb-link:after, article.post-preview.blacklisted.blacklisted-active a.bbb-thumb-link:before, div.post.post-preview.blacklisted.blacklisted-active div.preview a.bbb-thumb-link:after, div.post.post-preview.blacklisted.blacklisted-active div.preview a.bbb-thumb-link:before {content: none;}' + // Don't display when actively blacklisted. - 'article.post-preview a.bbb-thumb-link, div.post.post-preview div.preview a.bbb-thumb-link {position: relative;}'; // Allow the overlays to position relative to the link. - - for (i = 0; i < sbsl; i++) { - statusBorderItem = status_borders[i]; - - if (statusBorderItem.is_enabled) - styles += 'article.post-preview.' + statusBorderItem.class_name + ' a.bbb-thumb-link.bbb-custom-tag:after, article.post-preview.' + statusBorderItem.class_name + ' a.bbb-thumb-link.bbb-custom-tag:before, div.post.post-preview.' + statusBorderItem.class_name + ' div.preview a.bbb-thumb-link.bbb-custom-tag:after, div.post.post-preview.' + statusBorderItem.class_name + ' div.preview a.bbb-thumb-link.bbb-custom-tag:before {margin: ' + (border_width + border_spacing + customBorderSpacing) + 'px !important}'; // Margin applies to posts with a status and custom border. - } + styles += 'article.post-preview.blacklisted a.bbb-thumb-link:after, div.post.post-preview.blacklisted div.preview a.bbb-thumb-link:after {content: "\\A0"; position: absolute; bottom: 0px; right: 0px; height: 20px; width: 20px; line-height: 20px; font-weight: bold; color: #FFFFFF; background: rgba(0, 0, 0, 0.5) url(\'' + bbbBlacklistIcon + '\');}'; // Create blacklist overlay. } else if (blacklist_thumb_mark === "highlight") { styles += 'article.post-preview.blacklisted, div.post.post-preview.blacklisted div.preview {background-color: ' + blacklist_highlight_color + ' !important;}' + From 38011d5bb382f896f57148abb55a89796b39259f Mon Sep 17 00:00:00 2001 From: Moebius-Strip Date: Sat, 12 Sep 2015 13:34:40 -0400 Subject: [PATCH 03/27] Fix search add toggle & autocomplete compatibility * Added another listener for handling input changes performed by autocomplete via a mouse click. --- better-better-booru.user.js | 1 + 1 file changed, 1 insertion(+) diff --git a/better-better-booru.user.js b/better-better-booru.user.js index 1d44da7..9231e88 100644 --- a/better-better-booru.user.js +++ b/better-better-booru.user.js @@ -8462,6 +8462,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. tagsInput.addEventListener("cut", searchAddToggleCheck, false); tagsInput.addEventListener("paste", searchAddToggleCheck, false); tagsInput.addEventListener("change", searchAddToggleCheck, false); + $(tagsInput).on("autocompleteselect", function(event) { delayMe(function(event) { searchAddToggleCheck(event); }); }); // Delayed to allow autocomplete to change the input. } } From b685f3380147be254d217c461d06b116337d7444 Mon Sep 17 00:00:00 2001 From: Moebius-Strip Date: Mon, 14 Sep 2015 00:43:25 -0400 Subject: [PATCH 04/27] Storage methods * Changed from dot/bracket notation to the methods for local and session storage. * Created a custom setItem method to catch saving problems. --- better-better-booru.user.js | 76 +++++++++++++++++++++++++------------ 1 file changed, 52 insertions(+), 24 deletions(-) diff --git a/better-better-booru.user.js b/better-better-booru.user.js index 9231e88..f59c3ab 100644 --- a/better-better-booru.user.js +++ b/better-better-booru.user.js @@ -135,6 +135,26 @@ function bbbScript() { // This is needed to make this script work in Chrome. this.addEventListener("DOMNodeInserted", func, false); }; + Storage.prototype.bbbSetItem = function(key, value) { + // Store a value in storage and warn if it is full. + var targetStorage; + + if (this === localStorage) + targetStorage = localStorage; + else if (this === sessionStorage) + targetStorage = sessionStorage; + + try { + targetStorage.setItem(key, value); + } + catch (error) { + if (error.code === 22 || error.code === 1014) + bbbNotice("Your settings/data could not be saved. The browser storage is full", -1); + else + bbbNotice("Unexpected error while attmpting to save. (Error: " + error.message + ")", -1); + } + }; + /* Global Variables */ var bbb = { // Container for script info. blacklist: { @@ -602,7 +622,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. else if (mode === "pool_cache" || mode === "favorite_group_cache") { var collId = /\/(?:pools|favorite_groups)\/(\d+)/.exec(location.href)[1]; - sessionStorage["bbb_" + mode + "_" + collId] = new Date().getTime() + " " + xml.post_ids; + sessionStorage.bbbSetItem("bbb_" + mode + "_" + collId, new Date().getTime() + " " + xml.post_ids); searchJSON(optArg, xml); } else if (mode === "endless") { @@ -2836,10 +2856,12 @@ function bbbScript() { // This is needed to make this script work in Chrome. function loadSettings() { // Load stored settings. - if (typeof(localStorage.bbb_settings) === "undefined") + var settings = localStorage.getItem("bbb_settings"); + + if (settings === null) loadDefaults(); else { - bbb.user = JSON.parse(localStorage.bbb_settings); + bbb.user = JSON.parse(settings); checkUser(bbb.user, bbb.options); if (bbb.user.bbb_version !== bbb.options.bbb_version) { @@ -2894,7 +2916,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. bbb.user.blacklist_highlight_color = "#CCCCCC"; bbb.settings.changed = {}; - localStorage.bbb_settings = JSON.stringify(bbb.user); + localStorage.bbbSetItem("bbb_settings", JSON.stringify(bbb.user)); } function updateSettings() { @@ -2928,7 +2950,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. if (/500$/.test(bbb.user.thumb_cache_limit)) bbb.user.thumb_cache_limit = bbb.options.thumb_cache_limit.def; - if (!/\.(jpg|gif|png)/.test(localStorage.bbb_thumb_cache)) { + if (!/\.(jpg|gif|png)/.test(localStorage.getItem("bbb_thumb_cache"))) { localStorage.removeItem("bbb_thumb_cache"); loadThumbCache(); } @@ -2941,7 +2963,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. case "6.2.1": case "6.2.2": // Reset the thumb cache to deal with "download-preview" and incorrect extension entries. - if (localStorage.bbb_thumb_cache) { + if (localStorage.getItem("bbb_thumb_cache")) { localStorage.removeItem("bbb_thumb_cache"); loadThumbCache(); } @@ -4443,11 +4465,13 @@ function bbbScript() { // This is needed to make this script work in Chrome. function loadThumbCache() { // Initialize or load up the thumbnail cache. - if (typeof(localStorage.bbb_thumb_cache) !== "undefined") - bbb.cache.stored = JSON.parse(localStorage.bbb_thumb_cache); + var thumbCache = localStorage.getItem("bbb_thumb_cache"); + + if (thumbCache !== null) + bbb.cache.stored = JSON.parse(thumbCache); else { bbb.cache.stored = {history: [], names: {}}; - localStorage.bbb_thumb_cache = JSON.stringify(bbb.cache.stored); + localStorage.bbbSetItem("bbb_thumb_cache", JSON.stringify(bbb.cache.stored)); } } @@ -4489,7 +4513,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. delete bcs.names[removedIds[i]]; } - localStorage.bbb_thumb_cache = JSON.stringify(bcs); + localStorage.bbbSetItem("bbb_thumb_cache", JSON.stringify(bcs)); bbb.cache.current = {history: [], names: {}}; } @@ -4508,13 +4532,13 @@ function bbbScript() { // This is needed to make this script work in Chrome. delete bcs.names[removedIds[i]]; } - localStorage.bbb_thumb_cache = JSON.stringify(bcs); + localStorage.bbbSetItem("bbb_thumb_cache", JSON.stringify(bcs)); } function getIdCache() { // Retrieve the cached list of post IDs used for the pool/favorite group thumbnails. var collId = /\/(?:pools|favorite_groups)\/(\d+)/.exec(location.href)[1]; - var idCache = sessionStorage["bbb_" + gLoc + "_cache_" + collId]; + var idCache = sessionStorage.getItem("bbb_" + gLoc + "_cache_" + collId); var curTime = new Date().getTime(); var cacheTime; var timeDiff; @@ -4682,7 +4706,8 @@ function bbbScript() { // This is needed to make this script work in Chrome. var onValue = (bbb.user.endless_default !== "off" ? bbb.user.endless_default : "on"); var newDefault = (bbb.endless.enabled ? "off" : onValue); - sessionStorage.bbb_endless_default = endless_default = newDefault; + endless_default = newDefault; + sessionStorage.bbbSetItem("bbb_endless_default", newDefault); } if (bbb.endless.enabled) { @@ -4833,7 +4858,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. } // Check the session default or original default value to see if endless pages should be enabled. - var sessionDefault = sessionStorage.bbb_endless_default; + var sessionDefault = sessionStorage.getItem("bbb_endless_default"); if (endless_session_toggle && sessionDefault) endless_default = sessionDefault; @@ -5659,12 +5684,12 @@ function bbbScript() { // This is needed to make this script work in Chrome. // Update the blacklisted thumbnail info in the smart view object. var time = new Date().getTime(); var id = el.getAttribute("data-id"); - var smartView; + var smartView = localStorage.getItem("bbb_smart_view"); - if (typeof(localStorage.bbb_smart_view) === "undefined") // Initialize the object if it doesn't exist. + if (smartView === null) // Initialize the object if it doesn't exist. smartView = {last: time}; else { - smartView = JSON.parse(localStorage.bbb_smart_view); + smartView = JSON.parse(smartView); if (time - smartView.last > 60000) // Reset the object if it hasn't been changed within a minute. smartView = {last: time}; @@ -5677,17 +5702,20 @@ function bbbScript() { // This is needed to make this script work in Chrome. else delete smartView[id]; - localStorage.bbb_smart_view = JSON.stringify(smartView); + localStorage.bbbSetItem("bbb_smart_view", JSON.stringify(smartView)); } function blacklistSmartViewCheck(id) { // Check whether to display the post during the blacklist init. - if (!blacklist_smart_view || typeof(localStorage.bbb_smart_view) === "undefined") + var smartView = localStorage.getItem("bbb_smart_view"); + + if (!blacklist_smart_view || smartView === null) return false; else { - var smartView = JSON.parse(localStorage.bbb_smart_view); var time = new Date().getTime(); + smartView = JSON.parse(smartView); + if (time - smartView.last > 60000) { // Delete the ids if the object hasn't been changed within a minute. localStorage.removeItem("bbb_smart_view"); return false; @@ -7079,7 +7107,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. bbb.quick_search = bbb.el.quickSearchInput.value; if (searchDiv.bbbHasClass("bbb-quick-search-pinned")) - sessionStorage.bbb_quick_search = bbb.quick_search; + sessionStorage.bbbSetItem("bbb_quick_search", bbb.quick_search); else if (quick_search.indexOf("pinned") > -1) quickSearchPinEnable(); @@ -7197,7 +7225,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. } // Checked if the quick search has been pinned for this session. - var pinnedSearch = sessionStorage.bbb_quick_search; + var pinnedSearch = sessionStorage.getItem("bbb_quick_search"); if (pinnedSearch) { bbb.quick_search = pinnedSearch; @@ -7286,7 +7314,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. bbb.el.quickSearchDiv.bbbAddClass("bbb-quick-search-pinned"); if (bbb.quick_search) - sessionStorage.bbb_quick_search = bbb.quick_search; + sessionStorage.bbbSetItem("bbb_quick_search", bbb.quick_search); } function quickSearchPinDisable() { @@ -8766,4 +8794,4 @@ if (document.body) { } else // Operate normally. bbbScript(); -} +} \ No newline at end of file From 1cf309d17682dae70ee1b2b0d8f6803b4e0c1190 Mon Sep 17 00:00:00 2001 From: Moebius-Strip Date: Tue, 15 Sep 2015 02:10:29 -0400 Subject: [PATCH 05/27] Dialog window * Added a dialog window function to allow for more options than alert/confirm/prompt. --- better-better-booru.user.js | 303 ++++++++++++++++++++++++------------ 1 file changed, 201 insertions(+), 102 deletions(-) diff --git a/better-better-booru.user.js b/better-better-booru.user.js index f59c3ab..23004b4 100644 --- a/better-better-booru.user.js +++ b/better-better-booru.user.js @@ -151,7 +151,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. if (error.code === 22 || error.code === 1014) bbbNotice("Your settings/data could not be saved. The browser storage is full", -1); else - bbbNotice("Unexpected error while attmpting to save. (Error: " + error.message + ")", -1); + bbbNotice("Unexpected error while attempting to save. (Error: " + error.message + ")", -1); } }; @@ -174,6 +174,10 @@ function bbbScript() { // This is needed to make this script work in Chrome. searches: [], style_list: {} }, + dialog: { + flags: {}, + queue: [] + }, drag_scroll: { lastX: undefined, lastY: undefined, @@ -1818,7 +1822,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. function createMenu() { var menu = bbb.el.menu.window = document.createElement("div"); - menu.id = "bbb_menu"; + menu.id = "bbb-menu"; menu.style.visibility = "hidden"; var tip = bbb.el.menu.tip = document.createElement("div"); @@ -1975,49 +1979,6 @@ function bbbScript() { // This is needed to make this script work in Chrome. menu.appendChild(cancel); menu.appendChild(reset); - var tagEditBlocker = bbb.el.menu.tagEditBlocker = document.createElement("div"); - tagEditBlocker.className = "bbb-edit-blocker"; - menu.appendChild(tagEditBlocker); - - var tagEditBox = document.createElement("div"); - tagEditBox.className = "bbb-edit-box"; - tagEditBlocker.appendChild(tagEditBox); - - var tagEditHeader = document.createElement("h2"); - tagEditHeader.innerHTML = "Tag Editor"; - tagEditHeader.className = "bbb-header"; - tagEditBox.appendChild(tagEditHeader); - - var tagEditArea = bbb.el.menu.tagEditArea = document.createElement("textarea"); - tagEditArea.className = "bbb-edit-area"; - tagEditBox.appendChild(tagEditArea); - - var tagEditOk = document.createElement("a"); - tagEditOk.innerHTML = "OK"; - tagEditOk.href = "#"; - tagEditOk.className = "bbb-button"; - tagEditOk.addEventListener("click", function(event) { - var tags = searchMultiToSingle(tagEditArea.value); - var args = bbb.tagEdit; - - tagEditBlocker.style.display = "none"; - args.input.value = tags; - args.object[args.prop] = tags; - event.preventDefault(); - }, false); - tagEditBox.appendChild(tagEditOk); - - var tagEditCancel = document.createElement("a"); - tagEditCancel.innerHTML = "Cancel"; - tagEditCancel.href = "#"; - tagEditCancel.className = "bbb-button"; - tagEditCancel.style.cssFloat = "right"; - tagEditCancel.addEventListener("click", function(event) { - tagEditBlocker.style.display = "none"; - event.preventDefault(); - }, false); - tagEditBox.appendChild(tagEditCancel); - // Add menu to the DOM and manipulate the dimensions. document.body.appendChild(menu); @@ -2822,10 +2783,26 @@ function bbbScript() { // This is needed to make this script work in Chrome. } function tagEditWindow(input, object, prop) { - bbb.el.menu.tagEditBlocker.style.display = "block"; - bbb.el.menu.tagEditArea.value = searchSingleToMulti(input.value); - bbb.el.menu.tagEditArea.focus(); - bbb.tagEdit = {input: input, object: object, prop: prop}; + var tagEditBlocker = document.createDocumentFragment(); + + var tagEditHeader = document.createElement("h2"); + tagEditHeader.innerHTML = "Tag Editor"; + tagEditHeader.className = "bbb-header"; + tagEditBlocker.appendChild(tagEditHeader); + + var tagEditArea = bbb.el.menu.tagEditArea = document.createElement("textarea"); + tagEditArea.value = searchSingleToMulti(input.value); + tagEditArea.className = "bbb-edit-area"; + tagEditBlocker.appendChild(tagEditArea); + + var tagEditOk = function() { + var tags = searchMultiToSingle(tagEditArea.value); + + input.value = tags; + object[prop] = tags; + }; + + bbbDialog(tagEditBlocker, {ok: tagEditOk, cancel: true}); } function adjustMenuHeight() { @@ -3070,17 +3047,17 @@ function bbbScript() { // This is needed to make this script work in Chrome. checkUser(bbb.user, bbb.options); convertSettings("backup"); reloadMenu(); - alert("Backup settings loaded successfully. After reviewing the settings to ensure they are correct, please click \"save & close\" to finalize the restore."); + bbbDialog("Backup settings loaded successfully. After reviewing the settings to ensure they are correct, please click \"save & close\" to finalize the restore."); } catch (error) { if (error instanceof SyntaxError) - alert("The backup does not appear to be formatted correctly. Please make sure everything was pasted correctly/completely and that only one backup is provided."); + bbbDialog("The backup does not appear to be formatted correctly. Please make sure everything was pasted correctly/completely and that only one backup is provided."); else - alert("Unexpected error: " + error.message); + bbbDialog("Unexpected error: " + error.message); } } else - alert("A backup could not be detected in the text provided. Please make sure everything was pasted correctly/completely."); + bbbDialog("A backup could not be detected in the text provided. Please make sure everything was pasted correctly/completely."); } /* Post functions */ @@ -6021,6 +5998,125 @@ function bbbScript() { // This is needed to make this script work in Chrome. status.style.display = "none"; } + function bbbDialog(content, properties) { + // Open a dialog window that can have a predefined ok button (default) and/or cancel button. The properties object specifies dialog behavior and has the following values: + // ok/cancel: true to display the button, false to hide the button, function to display the button and specify a custom function for it + // condition: string to name a basic flag that will be checked/set by a dialog before displaying it, function to check custom conditions for a dialog before displaying it + // important: true to prioritize a dialog if it goes in the queue, false to allow a dialog to go to the end of the queue as normal + + var prop = properties || {}; + var okButton = (prop.ok === undefined ? true : prop.ok); + var cancelButton = (prop.cancel === undefined ? false : prop.cancel); + var condition = (prop.condition === undefined ? false : prop.condition); + var important = (prop.important === undefined ? false : prop.important); + + // Queue the dialog window if one is already open. + if (document.getElementById("bbb-dialog-blocker")) { + if (important) + bbb.dialog.queue.unshift({content: content, properties: properties}); + else + bbb.dialog.queue.push({content: content, properties: properties}); + + return; + } + + // Test whether the dialog window should be allowed to display. + if (condition) { + var conditionType = typeof(condition); + + if ((conditionType === "string" && bbb.dialog.flags[condition]) || (conditionType === "function" && condition())) { + nextBbbDialog(); + return; + } + else if (conditionType === "string") + bbb.dialog.flags[condition] = true; + } + + // Create the dialog window. + var blockDiv = document.createElement("div"); + blockDiv.id = "bbb-dialog-blocker"; + + var windowDiv = document.createElement("div"); + windowDiv.id = "bbb-dialog-window"; + blockDiv.appendChild(windowDiv); + + var contentDiv = windowDiv; + + if (okButton) { + var ok = document.createElement("a"); + ok.innerHTML = "OK"; + ok.href = "#"; + ok.className = "bbb-dialog-button"; + + if (typeof(okButton) === "function") + ok.addEventListener("click", okButton, false); + + ok.addEventListener("click", closeBbbDialog, false); + + okButton = ok; + } + + if (cancelButton) { + var cancel = document.createElement("a"); + cancel.innerHTML = "Cancel"; + cancel.href = "#"; + cancel.className = "bbb-dialog-button"; + cancel.style.cssFloat = "right"; + + if (typeof(cancelButton) === "function") + cancel.addEventListener("click", cancelButton, false); + + cancel.addEventListener("click", closeBbbDialog, false); + + cancelButton = cancel; + } + + if (okButton || cancelButton) { + contentDiv = document.createElement("div"); + contentDiv.className = "bbb-dialog-content-div"; + windowDiv.appendChild(contentDiv); + + var buttonDiv = document.createElement("div"); + buttonDiv.className = "bbb-dialog-button-div"; + windowDiv.appendChild(buttonDiv); + + if (okButton) + buttonDiv.appendChild(okButton); + + if (cancelButton) + buttonDiv.appendChild(cancelButton); + } + + if (typeof(content) === "string") + contentDiv.innerHTML = content; + else + contentDiv.appendChild(content); + + document.body.appendChild(blockDiv); + + (okButton || cancelButton).focus(); + } + + function closeBbbDialog(event) { + // Close the current dialog window. + var dialogBlocker = document.getElementById("bbb-dialog-blocker"); + + if (dialogBlocker) + document.body.removeChild(dialogBlocker); + + nextBbbDialog(); + + event.preventDefault(); + } + + function nextBbbDialog() { + // Open the next queued dialog window. + var nextDialog = bbb.dialog.queue.shift(); + + if (nextDialog) + bbbDialog(nextDialog.content, nextDialog.properties); + } + function thumbSearchMatch(post, searchArray) { // Take search objects and test them against a thumbnail's info. if (!searchArray[0]) @@ -6633,54 +6729,50 @@ function bbbScript() { // This is needed to make this script work in Chrome. var customStyles = document.createElement("style"); customStyles.type = "text/css"; - var styles = '#bbb_menu {background-color: #FFFFFF; border: 1px solid #CCCCCC; box-shadow: 0 2px 2px rgba(0, 0, 0, 0.5); padding: 15px; position: fixed; top: 25px; left: 50%; z-index: 9001;}' + - '#bbb_menu * {font-size: 14px; line-height: 16px; outline: 0px none; border: 0px none; margin: 0px; padding: 0px;}' + // Reset some base settings. - '#bbb_menu h1 {font-size: 24px; line-height: 42px;}' + - '#bbb_menu h2 {font-size: 16px; line-height: 25px;}' + - '#bbb_menu input, #bbb_menu select, #bbb_menu textarea {border: #CCCCCC 1px solid;}' + - '#bbb_menu input {height: 17px; padding: 1px 0px; margin-top: 4px; vertical-align: top;}' + - '#bbb_menu input[type="checkbox"] {margin: 0px; vertical-align: middle; position: relative; bottom: 2px;}' + - '#bbb_menu .bbb-general-input input[type="text"], #bbb_menu .bbb-general-input select {width: 175px;}' + - '#bbb_menu select {height: 21px; margin-top: 4px; vertical-align: top;}' + - '#bbb_menu option {padding: 0px 3px;}' + - '#bbb_menu textarea {padding: 2px; resize: none;}' + - '#bbb_menu ul, #bbb_menu ol {list-style: outside disc none; margin-top: 0px; margin-bottom: 0px; margin-left: 20px; display: block;}' + - '#bbb_menu .bbb-scroll-div {border: 1px solid #CCCCCC; margin: -1px 0px 5px 0px; padding: 5px 0px; overflow-y: auto;}' + - '#bbb_menu .bbb-page {position: relative; display: none;}' + - '#bbb_menu .bbb-button {border: 1px solid #CCCCCC; border-radius: 5px; display: inline-block; padding: 5px;}' + - '#bbb_menu .bbb-tab {border-top-left-radius: 5px; border-top-right-radius: 5px; display: inline-block; padding: 5px; border: 1px solid #CCCCCC; margin-right: -1px;}' + - '#bbb_menu .bbb-active-tab {background-color: #FFFFFF; border-bottom-width: 0px; padding-bottom: 6px;}' + - '#bbb_menu .bbb-header {border-bottom: 2px solid #CCCCCC; margin-bottom: 5px; width: 700px;}' + - '#bbb_menu .bbb-toc {list-style-type: upper-roman; margin-left: 30px;}' + - '#bbb_menu .bbb-section-options, #bbb_menu .bbb-section-text {margin-bottom: 5px; max-width: 902px;}' + - '#bbb_menu .bbb-section-options-left, #bbb_menu .bbb-section-options-right {display: inline-block; vertical-align: top; width: 435px;}' + - '#bbb_menu .bbb-section-options-left {border-right: 1px solid #CCCCCC; margin-right: 15px; padding-right: 15px;}' + - '#bbb_menu .bbb-general-label {display: block; height: 29px; padding: 0px 5px;}' + - '#bbb_menu .bbb-general-label:hover {background-color: #EEEEEE;}' + - '#bbb_menu .bbb-general-text {line-height: 29px;}' + - '#bbb_menu .bbb-general-input {float: right; line-height: 29px;}' + - '#bbb_menu .bbb-expl-link {font-size: 12px; font-weight: bold; margin-left: 5px; padding: 2px;}' + - '#bbb_menu .bbb-border-div {background-color: #EEEEEE; padding: 2px; margin: 0px 5px 0px 0px;}' + - '#bbb_menu .bbb-border-bar, #bbb_menu .bbb-border-settings {height: 29px; padding: 0px 2px; overflow: hidden;}' + - '#bbb_menu .bbb-border-settings {background-color: #FFFFFF;}' + - '#bbb_menu .bbb-border-div label, #bbb_menu .bbb-border-div span {display: inline-block; line-height: 29px;}' + - '#bbb_menu .bbb-border-name {text-align: left; width: 540px;}' + - '#bbb_menu .bbb-border-name input {width:460px;}' + - '#bbb_menu .bbb-border-color {text-align: center; width: 210px;}' + - '#bbb_menu .bbb-border-color input {width: 148px;}' + - '#bbb_menu .bbb-border-style {float: right; text-align: right; width: 130px;}' + - '#bbb_menu .bbb-border-divider {height: 4px;}' + - '#bbb_menu .bbb-insert-highlight .bbb-border-divider {background-color: blue; cursor: pointer;}' + - '#bbb_menu .bbb-no-highlight .bbb-border-divider {background-color: transparent; cursor: auto;}' + - '#bbb_menu .bbb-border-button {border: 1px solid #CCCCCC; border-radius: 5px; display: inline-block; padding: 2px; margin: 0px 2px;}' + - '#bbb_menu .bbb-border-spacer {display: inline-block; height: 12px; width: 0px; border-right: 1px solid #CCCCCC; margin: 0px 5px;}' + - '#bbb_menu .bbb-backup-area {height: 300px; width: 896px; margin-top: 2px;}' + - '#bbb_menu .bbb-blacklist-area {height: 300px; width: 896px; margin-top: 2px;}' + - '#bbb_menu .bbb-edit-blocker {display: none; height: 100%; width: 100%; background-color: rgba(0, 0, 0, 0.33); position: fixed; top: 0px; left: 0px;}' + - '#bbb_menu .bbb-edit-box {height: 500px; width: 800px; margin-left: -412px; margin-top: -262px; position: fixed; left: 50%; top: 50%; background-color: #FFFFFF; border: 2px solid #CCCCCC; padding: 10px; box-shadow: 0 2px 2px rgba(0, 0, 0, 0.5);}' + - '#bbb_menu .bbb-edit-text {margin-bottom: 5px;}' + - '#bbb_menu .bbb-edit-area {height: 429px; width: 794px; margin-bottom: 5px;}' + - '#bbb_menu .bbb-edit-link {background-color: #FFFFFF; border: 1px solid #CCCCCC; display: inline-block; height: 19px; line-height: 19px; margin-left: -1px; padding: 0px 2px; margin-top: 4px; text-align: center; vertical-align: top;}' + + var styles = '#bbb-menu {background-color: #FFFFFF; border: 1px solid #CCCCCC; box-shadow: 0 2px 2px rgba(0, 0, 0, 0.5); padding: 15px; position: fixed; top: 25px; left: 50%; z-index: 9001;}' + + '#bbb-menu *, #bbb-dialog-window * {font-size: 14px; line-height: 16px; outline: 0px none; border: 0px none; margin: 0px; padding: 0px;}' + // Reset some base settings. + '#bbb-menu h1, #bbb-dialog-window h1 {font-size: 24px; line-height: 42px;}' + + '#bbb-menu h2, #bbb-dialog-window h2 {font-size: 16px; line-height: 25px;}' + + '#bbb-menu input, #bbb-menu select, #bbb-menu textarea, #bbb-dialog-window input, #bbb-dialog-window select, #bbb-dialog-window textarea {border: #CCCCCC 1px solid;}' + + '#bbb-menu input {height: 17px; padding: 1px 0px; margin-top: 4px; vertical-align: top;}' + + '#bbb-menu input[type="checkbox"] {margin: 0px; vertical-align: middle; position: relative; bottom: 2px;}' + + '#bbb-menu .bbb-general-input input[type="text"], #bbb-menu .bbb-general-input select {width: 175px;}' + + '#bbb-menu select {height: 21px; margin-top: 4px; vertical-align: top;}' + + '#bbb-menu option {padding: 0px 3px;}' + + '#bbb-menu textarea, #bbb-dialog-window textarea {padding: 2px; resize: none;}' + + '#bbb-menu ul, #bbb-menu ol, #bbb-dialog-window ul, #bbb-dialog-window ol {list-style: outside disc none; margin-top: 0px; margin-bottom: 0px; margin-left: 20px; display: block;}' + + '#bbb-menu .bbb-scroll-div {border: 1px solid #CCCCCC; margin: -1px 0px 5px 0px; padding: 5px 0px; overflow-y: auto;}' + + '#bbb-menu .bbb-page {position: relative; display: none;}' + + '#bbb-menu .bbb-button {border: 1px solid #CCCCCC; border-radius: 5px; display: inline-block; padding: 5px;}' + + '#bbb-menu .bbb-tab {border-top-left-radius: 5px; border-top-right-radius: 5px; display: inline-block; padding: 5px; border: 1px solid #CCCCCC; margin-right: -1px;}' + + '#bbb-menu .bbb-active-tab {background-color: #FFFFFF; border-bottom-width: 0px; padding-bottom: 6px;}' + + '#bbb-menu .bbb-header, #bbb-dialog-window .bbb-header {border-bottom: 2px solid #CCCCCC; margin-bottom: 5px; width: 700px;}' + + '#bbb-menu .bbb-toc {list-style-type: upper-roman; margin-left: 30px;}' + + '#bbb-menu .bbb-section-options, #bbb-menu .bbb-section-text {margin-bottom: 5px; max-width: 902px;}' + + '#bbb-menu .bbb-section-options-left, #bbb-menu .bbb-section-options-right {display: inline-block; vertical-align: top; width: 435px;}' + + '#bbb-menu .bbb-section-options-left {border-right: 1px solid #CCCCCC; margin-right: 15px; padding-right: 15px;}' + + '#bbb-menu .bbb-general-label {display: block; height: 29px; padding: 0px 5px;}' + + '#bbb-menu .bbb-general-label:hover {background-color: #EEEEEE;}' + + '#bbb-menu .bbb-general-text {line-height: 29px;}' + + '#bbb-menu .bbb-general-input {float: right; line-height: 29px;}' + + '#bbb-menu .bbb-expl-link {font-size: 12px; font-weight: bold; margin-left: 5px; padding: 2px;}' + + '#bbb-menu .bbb-border-div {background-color: #EEEEEE; padding: 2px; margin: 0px 5px 0px 0px;}' + + '#bbb-menu .bbb-border-bar, #bbb-menu .bbb-border-settings {height: 29px; padding: 0px 2px; overflow: hidden;}' + + '#bbb-menu .bbb-border-settings {background-color: #FFFFFF;}' + + '#bbb-menu .bbb-border-div label, #bbb-menu .bbb-border-div span {display: inline-block; line-height: 29px;}' + + '#bbb-menu .bbb-border-name {text-align: left; width: 540px;}' + + '#bbb-menu .bbb-border-name input {width:460px;}' + + '#bbb-menu .bbb-border-color {text-align: center; width: 210px;}' + + '#bbb-menu .bbb-border-color input {width: 148px;}' + + '#bbb-menu .bbb-border-style {float: right; text-align: right; width: 130px;}' + + '#bbb-menu .bbb-border-divider {height: 4px;}' + + '#bbb-menu .bbb-insert-highlight .bbb-border-divider {background-color: blue; cursor: pointer;}' + + '#bbb-menu .bbb-no-highlight .bbb-border-divider {background-color: transparent; cursor: auto;}' + + '#bbb-menu .bbb-border-button {border: 1px solid #CCCCCC; border-radius: 5px; display: inline-block; padding: 2px; margin: 0px 2px;}' + + '#bbb-menu .bbb-border-spacer {display: inline-block; height: 12px; width: 0px; border-right: 1px solid #CCCCCC; margin: 0px 5px;}' + + '#bbb-menu .bbb-backup-area {height: 300px; width: 896px; margin-top: 2px;}' + + '#bbb-menu .bbb-blacklist-area {height: 300px; width: 896px; margin-top: 2px;}' + + '#bbb-menu .bbb-edit-link {background-color: #FFFFFF; border: 1px solid #CCCCCC; display: inline-block; height: 19px; line-height: 19px; margin-left: -1px; padding: 0px 2px; margin-top: 4px; text-align: center; vertical-align: top;}' + '#bbb-expl {background-color: #CCCCCC; border: 1px solid #000000; display: none; font-size: 12px; padding: 5px; position: fixed; max-width: 488px; width: 488px; overflow: hidden; z-index: 9002; box-shadow: 0 2px 2px rgba(0, 0, 0, 0.5);}' + '#bbb-expl * {font-size: 12px;}' + '#bbb-expl tiphead {display: block; font-weight: bold; text-decoration: underline; font-size: 13px; margin-top: 12px;}' + @@ -6691,7 +6783,14 @@ function bbbScript() { // This is needed to make this script work in Chrome. '#bbb-notice {padding: 3px; width: 100%; display: none; position: relative; z-index: 9002; border-radius: 2px; border: 1px solid #000000; background-color: #CCCCCC;}' + '#bbb-notice-msg {margin: 0px 25px 0px 55px; max-height: 200px; overflow: auto;}' + '#bbb-notice-msg .bbb-notice-msg-entry {border-bottom: solid 1px #000000; margin-bottom: 5px; padding-bottom: 5px;}' + - '#bbb-notice-msg .bbb-notice-msg-entry:last-child {border-bottom: none 0px; margin-bottom: 0px; padding-bottom: 0px;}'; + '#bbb-notice-msg .bbb-notice-msg-entry:last-child {border-bottom: none 0px; margin-bottom: 0px; padding-bottom: 0px;}' + + '#bbb-dialog-blocker {display: block; position: fixed; top: 0px; left: 0px; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.33); z-index: 9003; text-align: center;}' + + '#bbb-dialog-blocker:before {content: ""; display: inline-block; height: 100%; vertical-align: middle;}' + // Helps vertically center an element with unknown dimensions: https://css-tricks.com/centering-in-the-unknown/ + '#bbb-dialog-window {display: inline-block; display: inline-flex; flex-flow: column; position: relative; background-color: #FFFFFF; border: 10px solid #FFFFFF; outline: 1px solid #CCC; box-shadow: 0px 3px 3px rgba(0, 0, 0, 0.5); color: #000000; max-width: 940px; max-height: 90%; overflow-x: hidden; overflow-y: auto; text-align: left; vertical-align: middle;}' + + '#bbb-dialog-window .bbb-dialog-button {border: 1px solid #CCCCCC; border-radius: 5px; display: inline-block; padding: 5px; margin: 0px 5px;}' + + '#bbb-dialog-window .bbb-dialog-content-div {padding: 5px; overflow-x: hidden; overflow-y: auto;}' + + '#bbb-dialog-window .bbb-dialog-button-div {padding-top: 10px; flex-grow: 0; flex-shrink: 0; overflow: hidden;}' + + '#bbb-dialog-window .bbb-edit-area {height: 300px; width: 800px;}'; // Provide a little extra space for listings that allow thumbnail_count. if (thumbnail_count && (gLoc === "search" || gLoc === "notes" || gLoc === "favorites")) { From af0546dfc11392be15c4fd9ac6353468daa843e6 Mon Sep 17 00:00:00 2001 From: Moebius-Strip Date: Tue, 15 Sep 2015 19:29:27 -0400 Subject: [PATCH 06/27] Dialog focus tweak * Allow focus on the window if no buttons exist. --- better-better-booru.user.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/better-better-booru.user.js b/better-better-booru.user.js index 23004b4..0c44333 100644 --- a/better-better-booru.user.js +++ b/better-better-booru.user.js @@ -6038,6 +6038,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. var windowDiv = document.createElement("div"); windowDiv.id = "bbb-dialog-window"; + windowDiv.tabIndex = "-1"; blockDiv.appendChild(windowDiv); var contentDiv = windowDiv; @@ -6094,7 +6095,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. document.body.appendChild(blockDiv); - (okButton || cancelButton).focus(); + (okButton || cancelButton || windowDiv).focus(); } function closeBbbDialog(event) { From d3c43a997cf19b6c7225d3eecb5590e732ffd686 Mon Sep 17 00:00:00 2001 From: Moebius-Strip Date: Wed, 16 Sep 2015 15:27:09 -0400 Subject: [PATCH 07/27] Twitter image source update * Updated the twitter meta image source to use the new name value. --- better-better-booru.user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/better-better-booru.user.js b/better-better-booru.user.js index 0c44333..8c172d3 100644 --- a/better-better-booru.user.js +++ b/better-better-booru.user.js @@ -1467,7 +1467,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. 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 twitterInfo = getMeta("twitter:image:src", target); + var twitterInfo = getMeta("twitter:image", target); var previewInfo = getMeta("og:image", target); var imgHeight = Number(imgContainer.getAttribute("data-height")); var imgWidth = Number(imgContainer.getAttribute("data-width")); From 42bae4379c1afd5e343e5416304bb944164984ca Mon Sep 17 00:00:00 2001 From: Moebius-Strip Date: Wed, 16 Sep 2015 15:42:04 -0400 Subject: [PATCH 08/27] "Video with sound" loop update * Updated videos with audio so they don't loop by default. --- better-better-booru.user.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/better-better-booru.user.js b/better-better-booru.user.js index 8c172d3..5d60d67 100644 --- a/better-better-booru.user.js +++ b/better-better-booru.user.js @@ -769,6 +769,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. if (post.file_ext === "swf") // Create flash object. imgContainer.innerHTML = '

Save this flash (right click and save)

'; else if (post.file_ext === "webm" || post.file_ext === "mp4") { // Create video + var playerLoop = (post.has_sound ? '' : ' loop="loop"'); // No looping for videos with sound. var origVideo = imgContainer.getElementsByTagName("video")[0]; // Keep the original video from continuing to play after being removed. Why does it even do this...? @@ -778,7 +779,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. origVideo.load(); } - imgContainer.innerHTML = '

Save this video (right click and save)

'; + imgContainer.innerHTML = '

Save this video (right click and save)

'; } else if (post.file_ext === "zip" && /(?:^|\s)ugoira(?:$|\s)/.test(post.tag_string)) { // Create ugoira var useUgoiraOrig = getVar("original"); From c1961b8617c0a8bc72e92249442722c8a5e28730 Mon Sep 17 00:00:00 2001 From: Moebius-Strip Date: Sun, 20 Sep 2015 11:50:31 -0400 Subject: [PATCH 09/27] Stop original ugoira sample videos * Prevent the original ugoira videos from continuing to download/play after being removed by using the same method used on regular videos. --- better-better-booru.user.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/better-better-booru.user.js b/better-better-booru.user.js index 5d60d67..128e44e 100644 --- a/better-better-booru.user.js +++ b/better-better-booru.user.js @@ -765,19 +765,20 @@ function bbbScript() { // This is needed to make this script work in Chrome. // Replace the "resize to window" link with new resize links. modifyResizeLink(); + // Keep any original video from continuing to play/download after being removed. + var origVideo = imgContainer.getElementsByTagName("video")[0]; + + if (origVideo) { + origVideo.pause(); + origVideo.src = "about:blank"; + origVideo.load(); + } + // Create content. if (post.file_ext === "swf") // Create flash object. imgContainer.innerHTML = '

Save this flash (right click and save)

'; else if (post.file_ext === "webm" || post.file_ext === "mp4") { // Create video var playerLoop = (post.has_sound ? '' : ' loop="loop"'); // No looping for videos with sound. - var origVideo = imgContainer.getElementsByTagName("video")[0]; - - // Keep the original video from continuing to play after being removed. Why does it even do this...? - if (origVideo) { - origVideo.pause(); - origVideo.src = "about:blank"; - origVideo.load(); - } imgContainer.innerHTML = '

Save this video (right click and save)

'; } From 950a4f4bfb41b3a1f3f0680f300c2e0e13ed143f Mon Sep 17 00:00:00 2001 From: Moebius-Strip Date: Sun, 20 Sep 2015 12:03:47 -0400 Subject: [PATCH 10/27] Prevent sessionStorage inheritance * Added some preventative measures to keep tab specific settings for endless pages (session toggle) and quick search (pinned) from carrying over to new tabs. --- better-better-booru.user.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/better-better-booru.user.js b/better-better-booru.user.js index 128e44e..e95440e 100644 --- a/better-better-booru.user.js +++ b/better-better-booru.user.js @@ -4740,6 +4740,9 @@ function bbbScript() { // This is needed to make this script work in Chrome. function endlessInit() { // Set up and start endless pages. + if (window.opener && history.length === 1) + sessionStorage.removeItem("bbb_endless_default"); + if (endless_default === "disabled" || (gLoc !== "search" && gLoc !== "pool" && gLoc !== "notes" && gLoc !== "favorites" && gLoc !== "favorite_group")) return; @@ -7182,6 +7185,9 @@ function bbbScript() { // This is needed to make this script work in Chrome. function quickSearch() { // Set up quick search. + if (window.opener && history.length === 1) + sessionStorage.removeItem("bbb_quick_search"); + if (quick_search === "disabled" || (gLoc !== "search" && gLoc !== "notes" && gLoc !== "favorites" && gLoc !== "pool" && gLoc !== "popular" && gLoc !== "popular_view" && gLoc !== "favorite_group")) return; From 7807904365dbbd12de834683a6a6f268cc616ae1 Mon Sep 17 00:00:00 2001 From: Moebius-Strip Date: Sun, 20 Sep 2015 22:51:49 -0400 Subject: [PATCH 11/27] sessionStorage inheritance update * Prevent the sessionStorage reset from happening in response to a page refresh. --- better-better-booru.user.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/better-better-booru.user.js b/better-better-booru.user.js index e95440e..beb9977 100644 --- a/better-better-booru.user.js +++ b/better-better-booru.user.js @@ -4740,8 +4740,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. function endlessInit() { // Set up and start endless pages. - if (window.opener && history.length === 1) - sessionStorage.removeItem("bbb_endless_default"); + resetSessionStorage("bbb_endless_default"); if (endless_default === "disabled" || (gLoc !== "search" && gLoc !== "pool" && gLoc !== "notes" && gLoc !== "favorites" && gLoc !== "favorite_group")) return; @@ -7185,8 +7184,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. function quickSearch() { // Set up quick search. - if (window.opener && history.length === 1) - sessionStorage.removeItem("bbb_quick_search"); + resetSessionStorage("bbb_quick_search"); if (quick_search === "disabled" || (gLoc !== "search" && gLoc !== "notes" && gLoc !== "favorites" && gLoc !== "pool" && gLoc !== "popular" && gLoc !== "popular_view" && gLoc !== "favorite_group")) return; @@ -8332,6 +8330,20 @@ function bbbScript() { // This is needed to make this script work in Chrome. return false; } + function resetSessionStorage(key) { + // Remove an inherited sessionStorage key for a new tab/window. + if (window.opener && history.length === 1) { + var state = history.state || {}; + var stateProperty = key + "_reset"; + + if (!state[stateProperty]) { + sessionStorage.removeItem(key); + state[stateProperty] = true; + history.replaceState(state, "", location.href); + } + } + } + function accountSettingCheck(scriptSetting) { // Determine whether the script setting or account/anonymous setting should be used. var loggedIn = isLoggedIn(); From 82b01a468830b87af4d0ab3421d708623972c1e8 Mon Sep 17 00:00:00 2001 From: Moebius-Strip Date: Sun, 20 Sep 2015 22:58:33 -0400 Subject: [PATCH 12/27] Retain history state * Keep the history state when updating a thumb listing. --- 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 beb9977..7edf336 100644 --- a/better-better-booru.user.js +++ b/better-better-booru.user.js @@ -734,7 +734,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. // Update the URL with the limit value. if (allowUserLimit()) - history.replaceState({}, "", updateURLQuery(location.search, {limit: thumbnail_count})); + history.replaceState((history.state || {}), "", updateURLQuery(location.search, {limit: thumbnail_count})); } function parsePost(postInfo) { @@ -1370,7 +1370,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. // Update the URL with the limit value. if (allowUserLimit()) - history.replaceState({}, "", updateURLQuery(location.search, {limit: thumbnail_count})); + history.replaceState((history.state || {}), "", updateURLQuery(location.search, {limit: thumbnail_count})); } function replaceHidden(docEl) { From d5d9f0a4dc22d2ecd532ceed63629f7c39194cae Mon Sep 17 00:00:00 2001 From: Moebius-Strip Date: Tue, 29 Sep 2015 23:43:26 -0400 Subject: [PATCH 13/27] Ugoira slider update * Updated to support Danbooru's changes to the ugoira slider during loading. * Renamed the session storage cleanup function. --- better-better-booru.user.js | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/better-better-booru.user.js b/better-better-booru.user.js index 7edf336..a5dca9d 100644 --- a/better-better-booru.user.js +++ b/better-better-booru.user.js @@ -796,7 +796,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. noteToggleLinkInit(); } else { // Load original ugoira version. - imgContainer.innerHTML = '
'; + imgContainer.innerHTML = '
'; // Make notes toggle when clicking the ugoira animation. noteToggleInit(); @@ -4161,13 +4161,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. $(function() { Danbooru.Ugoira.create_player(); $(Danbooru.Ugoira.player).on("loadProgress", function(event, progress) { - $("#ugoira-load-percentage").text(Math.floor(progress * 100)); - }); - $(Danbooru.Ugoira.player).on("loadingStateChanged", function(event, state) { - if (state === 2) { - $("#ugoira-load-progress").remove(); - $("#seek-slider").show(); - } + $("#seek-slider").progressbar("value", Math.floor(progress * 100)); }); var player_manually_paused = false; @@ -4187,6 +4181,10 @@ function bbbScript() { // This is needed to make this script work in Chrome. event.preventDefault(); }); + $("#seek-slider").progressbar({ + value: 0 + }); + $("#seek-slider").slider({ min: 0, max: Danbooru.Ugoira.player._frameCount-1, @@ -4740,7 +4738,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. function endlessInit() { // Set up and start endless pages. - resetSessionStorage("bbb_endless_default"); + removeInheritedStorage("bbb_endless_default"); if (endless_default === "disabled" || (gLoc !== "search" && gLoc !== "pool" && gLoc !== "notes" && gLoc !== "favorites" && gLoc !== "favorite_group")) return; @@ -7184,7 +7182,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. function quickSearch() { // Set up quick search. - resetSessionStorage("bbb_quick_search"); + removeInheritedStorage("bbb_quick_search"); if (quick_search === "disabled" || (gLoc !== "search" && gLoc !== "notes" && gLoc !== "favorites" && gLoc !== "pool" && gLoc !== "popular" && gLoc !== "popular_view" && gLoc !== "favorite_group")) return; @@ -8330,7 +8328,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. return false; } - function resetSessionStorage(key) { + function removeInheritedStorage(key) { // Remove an inherited sessionStorage key for a new tab/window. if (window.opener && history.length === 1) { var state = history.state || {}; From b5301a6872334abf178b2426686da1ffe3f2588d Mon Sep 17 00:00:00 2001 From: Moebius-Strip Date: Sat, 10 Oct 2015 01:07:48 -0400 Subject: [PATCH 14/27] Danbooru blacklist updates * Updated to support Danbooru's changes to blacklist persistence. * Misc. cleanup. --- better-better-booru.user.js | 44 +++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/better-better-booru.user.js b/better-better-booru.user.js index a5dca9d..29e5350 100644 --- a/better-better-booru.user.js +++ b/better-better-booru.user.js @@ -6,9 +6,7 @@ // @version 7.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 http://*.donmai.us/* -// @match https://*.donmai.us/* -// @match http://donmai.us/* +// @match *://*.donmai.us/* // @run-at document-end // @grant none // @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAAAAABWESUoAAAA9klEQVQ4y2NgGBgQu/Dau1/Pt/rhVPAfCkpwKXhUZ8Al2vT//yu89vDjV8AkP/P//zY0K//+eHVmoi5YyB7I/VDGiKYADP60wRT8P6aKTcH//0lgQcHS//+PYFdwFu7Ib8gKGBgYOQ22glhfGO7mqbEpzv///xyqAiAQAbGewIz8aoehQArEWsyQsu7O549XJiowoCpg4rM9CGS8V8UZ9GBwy5wBr4K/teL4Ffz//8mHgIL/v82wKgA6kkXE+zKIuRaHAhDQATFf4lHABmL+xKPAFhKUOBQwSyU+AzFXEvDFf3sCCnrxh8O3Ujwh+fXZvjoZ+udTAERqR5IgKEBRAAAAAElFTkSuQmCC @@ -303,7 +301,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. show_shota: newOption("checkbox", false, "Show Shota", "Display shota posts in the search, pool, popular, favorites, comments, notes, and favorite group listings."), show_toddlercon: newOption("checkbox", false, "Show Toddlercon", "Display toddlercon posts in the search, pool, popular, favorites, comments, notes, and favorite group listings."), single_color_borders: newOption("checkbox", false, "Single Color Borders", "Only use one color for each thumbnail border."), - thumb_info: newOption("dropdown", "disabled", "Thumbnail Info", "Display the score(★), favorite count(♥), and rating (S, Q, or E) for a post with its thumbnail. Below: Display the extra information below thumbnails. Hover: Display the extra information upon hovering over a thumbnail's area. NoteExtra information will not be added to the thumbnails in the comments listing since the score and rating are already visible there. Instead, the number of favorites will be added next to the existing score display.", {txtOptions:["Disabled:disabled", "Below:below", "Hover:hover"]}), + thumb_info: newOption("dropdown", "disabled", "Thumbnail Info", "Display the score (★), favorite count (♥), and rating (S, Q, or E) for a post with its thumbnail. Below: Display the extra information below thumbnails. Hover: Display the extra information upon hovering over a thumbnail's area. NoteExtra information will not be added to the thumbnails in the comments listing since the score and rating are already visible there. Instead, the number of favorites will be added next to the existing score display.", {txtOptions:["Disabled:disabled", "Below:below", "Hover:hover"]}), thumbnail_count: newOption("dropdown", 0, "Thumbnail Count", "Change the number of thumbnails that display in the search, favorites, and notes listings.", {txtOptions:["Disabled:0"], numRange:[1,200]}), track_new: newOption("checkbox", false, "Track New Posts", "Add a menu option titled \"new\" to the posts section submenu (between \"listing\" and \"upload\") that links to a customized search focused on keeping track of new posts.NoteWhile browsing the new posts, the current page of posts is also tracked. If the new post listing is left, clicking the \"new\" link later on will attempt to pull up the posts where browsing was left off at.TipIf you would like to bookmark the new post listing, drag and drop the link to your bookmarks or right click it and bookmark/copy the location from the context menu."), status_borders: borderSet(["deleted", true, "#000000", "solid", "post-status-deleted"], ["flagged", true, "#FF0000", "solid", "post-status-flagged"], ["pending", true, "#0000FF", "solid", "post-status-pending"], ["child", true, "#CCCC00", "solid", "post-status-has-parent"], ["parent", true, "#00FF00", "solid", "post-status-has-children"]), @@ -1457,7 +1455,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. /* Functions for retrieving page info */ function scrapePost(pageEl) { - // Retrieve info from the current document or a supplied element containing the html with it. + // Retrieve info from the current document or a supplied element containing the HTML with it. var target = pageEl || document; var postContent = getPostContent(target); var imgContainer = postContent.container; @@ -5241,7 +5239,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. // Create the blacklist section. var cookies = getCookie(); - var blacklistDisabled = (cookies["disable-all-blacklists"] === "1" && blacklistBox); + var blacklistDisabled = (cookies.dab === "1" && blacklistBox); for (i = 0, il = blacklistTags.length; i < il; i++) { var blacklistTag = blacklistTags[i].bbbSpaceClean(); @@ -5249,7 +5247,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. if (blacklistSearch[0]) { var entryHash = blacklistTag.bbbHash(); - var entryDisabled = (blacklistDisabled || (cookies["bl:" + entryHash] === "1") ? true : false); + var entryDisabled = (blacklistDisabled || (cookies["b" + entryHash] === "1") ? true : false); var newEntry = {active: !entryDisabled, tags:blacklistTag, search:blacklistSearch, matches: [], index: i, hash: entryHash}; bbb.blacklist.entries.push(newEntry); @@ -5307,9 +5305,20 @@ function bbbScript() { // This is needed to make this script work in Chrome. if (event.button !== 0) return; - var blacklistDisabled = (getCookie()["disable-all-blacklists"] === "1"); + var blacklistDisabled = (getCookie().dab === "1"); var entries = bbb.blacklist.entries; + if (blacklistDisabled) { + bbb.el.blacklistEnableLink.style.display = "none"; + bbb.el.blacklistDisableLink.style.display = "inline"; + createCookie("dab", 0, 365); + } + else { + bbb.el.blacklistEnableLink.style.display = "inline"; + bbb.el.blacklistDisableLink.style.display = "none"; + createCookie("dab", 1, 365); + } + for (var i = 0, il = entries.length; i < il; i++) { var entry = entries[i]; @@ -5320,18 +5329,9 @@ function bbbScript() { // This is needed to make this script work in Chrome. else { if (entry.active) blacklistEntryToggle(i); - } - } - if (blacklistDisabled) { - bbb.el.blacklistEnableLink.style.display = "none"; - bbb.el.blacklistDisableLink.style.display = "inline"; - createCookie("disable-all-blacklists", 0, 365); - } - else { - bbb.el.blacklistEnableLink.style.display = "inline"; - bbb.el.blacklistDisableLink.style.display = "none"; - createCookie("disable-all-blacklists", 1, 365); + createCookie("b" + entry.hash, 0, -1); + } } event.preventDefault(); @@ -5354,6 +5354,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. var entry = bbb.blacklist.entries[entryIndex]; var matches = entry.matches; var links = document.getElementsByClassName("bbb-blacklist-entry-" + entryIndex); + var blacklistDisabled = (getCookie().dab === "1"); var id; var els; var matchList; @@ -5362,7 +5363,8 @@ function bbbScript() { // This is needed to make this script work in Chrome. if (entry.active) { entry.active = false; - createCookie("bl:" + entry.hash, 1); + if (!blacklistDisabled) + createCookie("b" + entry.hash, 1); for (i = 0, il = links.length; i < il; i++) links[i].bbbAddClass("blacklisted-active"); @@ -5388,7 +5390,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. else { entry.active = true; - createCookie("bl:" + entry.hash, 0, -1); + createCookie("b" + entry.hash, 0, -1); for (i = 0, il = links.length; i < il; i++) links[i].bbbRemoveClass("blacklisted-active"); From ee91c50cde441be3018d4989aa0fb41be0291c29 Mon Sep 17 00:00:00 2001 From: Moebius-Strip Date: Sun, 25 Oct 2015 00:47:10 -0400 Subject: [PATCH 15/27] Efficiency tweaks * Modified the Danbooru blacklist and note functions so that they don't run extra times and cause unnecessary temporary changes that eat up time. --- better-better-booru.user.js | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/better-better-booru.user.js b/better-better-booru.user.js index 29e5350..e84800c 100644 --- a/better-better-booru.user.js +++ b/better-better-booru.user.js @@ -135,19 +135,12 @@ function bbbScript() { // This is needed to make this script work in Chrome. Storage.prototype.bbbSetItem = function(key, value) { // Store a value in storage and warn if it is full. - var targetStorage; - - if (this === localStorage) - targetStorage = localStorage; - else if (this === sessionStorage) - targetStorage = sessionStorage; - try { - targetStorage.setItem(key, value); + this.setItem(key, value); } catch (error) { if (error.code === 22 || error.code === 1014) - bbbNotice("Your settings/data could not be saved. The browser storage is full", -1); + bbbNotice("Your settings/data could not be saved. The browser storage is full.", -1); else bbbNotice("Unexpected error while attempting to save. (Error: " + error.message + ")", -1); } @@ -449,6 +442,8 @@ function bbbScript() { // This is needed to make this script work in Chrome. var bbbBlacklistIcon = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAMAAAC6V+0/AAAAkFBMVEUAAAD////////////////////////////////////////////////////////////////p6en////////////////////////////////////////////////////////+/v7///////////////////////////////////////////////////////////97JICZAAAAL3RSTlMACAQBoUSi5QcnMfmnsMW9VQno+vjsxrwstPyzMhOpSxS65vX06czqQf7NvqbzQKZY7GsAAADASURBVHhefZDnDoJAEITn8Kh3FAEFQbH3Mu//doaNLSFxfn7J7hT80cgJlAqc0S8bu55P+p47/rJQ8yUdflhCHq/WpjmZvKjSPPOyBFbZlNRKPFySzTaOANQJ6fZujsf9YUcjNMvpOQACn+kyLmjaObBI6QcAFGkRxYblLAIsqd4Q0ayUDzeBcr4A5q2h6U5Vfy5GeQbIh8l6I0YSKal72k3uhUSS8OQ0WwGPddFQq2/NPLW22rxrDgcZTvd35KGevk8VfmeGhUQAAAAASUVORK5CYII="; /* "INIT" */ + modifyDanbScript(); + customCSS(); // Contains the portions related to notices. delayMe(formatThumbnails); // Delayed to allow Danbooru to run first. @@ -856,7 +851,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. disableEmbeddedNotes(); // Load/reload notes. - Danbooru.Note.load_all(); + Danbooru.Note.load_all("bbb"); // Auto position the content if desired. autoscrollPost(); @@ -3379,7 +3374,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. // Reset notes with embedded notes enabled. Danbooru.Note.embed = true; noteContainer.innerHTML = ""; - Danbooru.Note.load_all(); + Danbooru.Note.load_all("bbb"); }; document.addEventListener("click", toggleFunction, true); // Override all other click events for the translate link. @@ -5711,6 +5706,20 @@ function bbbScript() { // This is needed to make this script work in Chrome. } /* Other functions */ + function modifyDanbScript() { + // Modify some Danbooru functions so that they don't run unnecessarily. + var loadNotes = Danbooru.Note.load_all; + + Danbooru.Note.load_all = function(allow) { + if (allow === "bbb") + loadNotes(); + }; + + Danbooru.Blacklist.initialize_all = function() { + return; + }; + } + function modifyPage() { // Determine what function may be needed to fix/update content. if (noXML()) From 5b8deb41c1586f17d3f59002573a5e263e2e53de Mon Sep 17 00:00:00 2001 From: Moebius-Strip Date: Mon, 16 Nov 2015 00:19:03 -0500 Subject: [PATCH 16/27] Automatic storage cleaning * Updated the storage set method so that it automatically tries to fix localStorage space problems by clearing out autocomplete data. --- better-better-booru.user.js | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/better-better-booru.user.js b/better-better-booru.user.js index e84800c..c0e1918 100644 --- a/better-better-booru.user.js +++ b/better-better-booru.user.js @@ -139,8 +139,30 @@ function bbbScript() { // This is needed to make this script work in Chrome. this.setItem(key, value); } catch (error) { - if (error.code === 22 || error.code === 1014) - bbbNotice("Your settings/data could not be saved. The browser storage is full.", -1); + if (error.code === 22 || error.code === 1014) { + if (this === localStorage) { + if (localStorage.length > 2000) { + // Try clearing out autocomplete if that appears to be the problem. + for (var i = localStorage.length - 1; i >= 0; i--) { + var keyName = localStorage.key(i); + + if (keyName.indexOf("ac-") === 0) + localStorage.removeItem(keyName); + } + + try { + this.setItem(key, value); + } + catch (error2) { + bbbNotice("Your settings/data could not be saved. The browser's local storage is full.", -1); + } + } + else + bbbNotice("Your settings/data could not be saved. The browser's local storage is full.", -1); + } + else + bbbNotice("Your settings/data could not be saved. The browser's session storage is full.", -1); + } else bbbNotice("Unexpected error while attempting to save. (Error: " + error.message + ")", -1); } From 71cd64c51c2e9301c870195f9b86d404903ac3c4 Mon Sep 17 00:00:00 2001 From: Moebius-Strip Date: Sun, 13 Dec 2015 23:07:02 -0500 Subject: [PATCH 17/27] Blacklist session toggle & Flags update * Added a "session toggle" option for making blacklist entries toggle permanently or temporarily. * Made a section specifically for flags and moved the XML and dialog flags to it. --- better-better-booru.user.js | 66 ++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 34 deletions(-) diff --git a/better-better-booru.user.js b/better-better-booru.user.js index c0e1918..b256889 100644 --- a/better-better-booru.user.js +++ b/better-better-booru.user.js @@ -151,7 +151,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. } try { - this.setItem(key, value); + localStorage.setItem(key, value); } catch (error2) { bbbNotice("Your settings/data could not be saved. The browser's local storage is full.", -1); @@ -188,7 +188,6 @@ function bbbScript() { // This is needed to make this script work in Chrome. style_list: {} }, dialog: { - flags: {}, queue: [] }, drag_scroll: { @@ -218,6 +217,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. sidebar: undefined, top: undefined }, + flags: {}, hotkeys: { other: { // Hotkeys for misc locations. 66: {func: openMenu}, // B @@ -258,6 +258,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. blacklist_thumb_controls: newOption("checkbox", false, "Thumbnail Controls", "Allow control over individual blacklisted thumbnails and access to blacklist toggle links from blacklisted thumbnails. DirectionsFor blacklisted thumbnails that have been revealed, hovering over them will reveal a clickable \"X\" icon that can hide them again.

If using the \"hidden\" or \"replaced\" post display options, clicking on the area of a blacklisted thumbnail will pop up a menu that displays what blacklist entries it matches. Clicking the thumbnail area a second time while that menu is open will reveal that single thumbnail.

The menu that pops up on the first click also allows for toggling any listed blacklist entry for the entire page and navigating to the post without revealing its thumbnail. NoteToggling blacklist entries will have no effect on posts that have been changed via their individual controls."), blacklist_post_display: newOption("dropdown", "removed", "Post Display", "Set how the display of blacklisted posts in thumbnail listings and the comments section is handled. Removed: The default Danbooru behavior where the posts and the space they take up are completely removed. Hidden: Post space is preserved, but thumbnails are hidden. Replaced: Thumbnails are replaced by \"blacklisted\" thumbnail placeholders.", {txtOptions:["Removed (Default):removed", "Hidden:hidden", "Replaced:replaced"]}), blacklist_smart_view: newOption("checkbox", false, "Smart View", "When navigating to a blacklisted post by using its thumbnail, if the thumbnail has already been revealed, the post content will temporarily be exempt from any blacklist checks for 1 minute and be immediately visible. NoteThumbnails in the parent/child notices of posts with exempt content will still be affected by the blacklist."), + blacklist_session_toggle: newOption("checkbox", true, "Session Toggle", "When toggling an individual blacklist entry on and off, the mode it's toggled to will persist across other pages in the same browsing session until it ends."), blacklist_thumb_mark: newOption("dropdown", "none", "Thumbnail Marking", "Mark the thumbnails of blacklisted posts that have been revealed to make them easier to distinguish from other thumbnails. Highlight: Change the background color of blacklisted thumbnails. Icon Overlay: Add an icon to the lower right corner of blacklisted thumbnails.", {txtOptions:["Disabled:none", "Highlight:highlight", "Icon Overlay:icon"]}), border_spacing: newOption("dropdown", 0, "Border Spacing", "Set the amount of blank space between a border and thumbnail and between a custom tag border and status border. NoteEven when set to 0, status borders and custom tag borders will always have a minimum value of 1 between them. TipUse this option if you often have trouble distinguishing a border from the thumbnail image.", {txtOptions:["0 (Default):0", "1:1", "2:2", "3:3"]}), border_width: newOption("dropdown", 2, "Border Width", "Set the width of thumbnail borders.", {txtOptions:["1:1", "2 (Default):2", "3:3", "4:4", "5:5"]}), @@ -332,7 +333,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. old: "" }, sections: { // Setting sections and ordering. - blacklist_options: newSection("general", ["blacklist_post_display", "blacklist_thumb_mark", "blacklist_highlight_color", "blacklist_thumb_controls", "blacklist_smart_view", "blacklist_add_bars"], "Options"), + blacklist_options: newSection("general", ["blacklist_session_toggle", "blacklist_post_display", "blacklist_thumb_mark", "blacklist_highlight_color", "blacklist_thumb_controls", "blacklist_smart_view", "blacklist_add_bars"], "Options"), border_options: newSection("general", ["custom_tag_borders", "custom_status_borders", "single_color_borders", "border_width", "border_spacing"], "Options"), browse: newSection("general", ["show_loli", "show_shota", "show_toddlercon", "show_banned", "show_deleted", "thumbnail_count", "thumb_info", "post_link_new_window"], "Post Browsing"), control: newSection("general", ["load_sample_first", "alternate_image_swap", "image_swap_mode", "post_resize", "post_resize_mode", "post_drag_scroll", "autoscroll_post", "disable_embedded_notes"], "Post Control"), @@ -349,13 +350,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. changed: {} }, timers: {}, - user: {}, // User settings. - xml: { // Active xml requests. False when successfully completed or not yet used. True when incomplete due to being in progress or an error. - endless: false, - hidden: false, - paginator: false, - thumbs: false - } + user: {} // User settings. }; loadSettings(); // Load user settings. @@ -377,6 +372,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. var direct_downloads = bbb.user.direct_downloads; var post_link_new_window = bbb.user.post_link_new_window; + var blacklist_session_toggle = bbb.user.blacklist_session_toggle; var blacklist_post_display = bbb.user.blacklist_post_display; var blacklist_thumb_mark = bbb.user.blacklist_thumb_mark; var blacklist_highlight_color = bbb.user.blacklist_highlight_color; @@ -532,7 +528,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. if (mode === "search" || mode === "notes" || mode === "favorites") { if (potentialHiddenPosts(mode)) { url = (allowUserLimit() ? updateURLQuery(url, {limit: thumbnail_count}) : url); - bbb.xml.thumbs = true; + bbb.flags.thumbs_xml = true; if (mode === "search") fetchJSON(url.replace(/\/?(?:posts)?\/?(?:\?|$)/, "/posts.json?"), "search"); @@ -546,7 +542,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. } else if (mode === "popular" || mode === "popular_view") { if (potentialHiddenPosts(mode)) { - bbb.xml.thumbs = true; + bbb.flags.thumbs_xml = true; fetchJSON(url.replace(/\/(popular_view|popular)\/?/, "/$1.json"), mode); bbbStatus("posts", "new"); @@ -555,7 +551,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. else if (mode === "pool" || mode === "favorite_group") { if (potentialHiddenPosts(mode)) { idCache = getIdCache(); - bbb.xml.thumbs = true; + bbb.flags.thumbs_xml = true; if (idCache) searchJSON(mode + "_search", {post_ids: idCache}); @@ -573,7 +569,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. fetchJSON("/posts.json?tags=status:any+id:" + idSearch.join(","), mode, idSearch); } else if (mode === "endless") { - bbb.xml.endless = true; + bbb.flags.endless_xml = true; if (gLoc === "pool" || gLoc === "favorite_group") { idCache = getIdCache(); @@ -632,7 +628,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. // Update status message. if (mode === "search" || mode === "popular" || mode === "popular_view" || mode === "notes" || mode === "favorites" || mode === "pool_search" || mode === "favorite_group_search") { - bbb.xml.thumbs = false; + bbb.flags.thumbs_xml = false; parseListing(xml, optArg); } @@ -645,7 +641,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. searchJSON(optArg, xml); } else if (mode === "endless") { - bbb.xml.endless = false; + bbb.flags.endless_xml = false; endlessXMLJSONHandler(xml, optArg); } @@ -1166,7 +1162,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. if (mode === "search" || mode === "notes" || mode === "favorites" || mode === "thumbnails") { if (allowUserLimit()) { url = updateURLQuery(location.href, {limit: thumbnail_count}); - bbb.xml.thumbs = true; + bbb.flags.thumbs_xml = true; fetchPages(url, "thumbnails"); bbbStatus("posts", "new"); @@ -1174,14 +1170,14 @@ function bbbScript() { // This is needed to make this script work in Chrome. } else if (mode === "endless") { url = endlessNexURL(); - bbb.xml.endless = true; + bbb.flags.endless_xml = true; fetchPages(url, "endless"); bbbStatus("posts", "new"); } else if (mode === "paginator") { url = (allowUserLimit() ? updateURLQuery(location.href, {limit: thumbnail_count}) : location.href); - bbb.xml.paginator = true; + bbb.flags.paginator_xml = true; fetchPages(url, "paginator"); } @@ -1193,7 +1189,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. } else if (mode === "hidden") { url = "/posts/" + optArg; - bbb.xml.hidden = true; + bbb.flags.hidden_xml = true; fetchPages(url, "hidden"); bbbStatus("hidden", "new"); @@ -1217,7 +1213,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. docEl.innerHTML = xmlhttp.responseText; if (mode === "paginator") { - bbb.xml.paginator = false; + bbb.flags.paginator_xml = false; replacePaginator(docEl); } @@ -1226,19 +1222,19 @@ function bbbScript() { // This is needed to make this script work in Chrome. bbbStatus("post_comments", "done"); } else if (mode === "thumbnails") { - bbb.xml.thumbs = false; + bbb.flags.thumbs_xml = false; replaceThumbnails(docEl); bbbStatus("posts", "done"); } else if (mode === "hidden") { - bbb.xml.hidden = false; + bbb.flags.hidden_xml = false; replaceHidden(docEl); bbbStatus("hidden", "done"); } else if (mode === "endless") { - bbb.xml.endless = false; + bbb.flags.endless_xml = false; endlessXMLPageHandler(docEl); bbbStatus("posts", "done"); @@ -1432,7 +1428,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. updateThumbCache(); } else { // The image information couldn't be found. - bbb.xml.hidden = true; // Flag the XML as active to signal a problem and disable further attempts. + bbb.flags.hidden_xml = true; // Flag the XML as active to signal a problem and disable further attempts. updateThumbCache(); bbbNotice("Error retrieving thumbnail information.", -1); @@ -4385,7 +4381,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. function fixHiddenThumbs() { // Fix hidden thumbnails by fetching the info from a page. - if (bbb.xml.hidden) + if (bbb.flags.hidden_xml) return; var hiddenImgs = document.getElementsByClassName("bbb-hidden-thumb"); @@ -4918,7 +4914,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. var postsDiv = (gLoc === "search" ? document.getElementById("posts") : undefined); var postsVisible = (!postsDiv || postsDiv.style.display !== "none"); - if (bbb.xml.thumbs || bbb.xml.paginator || !postsVisible) // Delay the check until the page is completely ready. + if (bbb.flags.thumbs_xml || bbb.flags.paginator_xml || !postsVisible) // Delay the check until the page is completely ready. endlessDelay(100); else { if (!bbb.endless.last_paginator) @@ -4956,7 +4952,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. function endlessRequestPage() { // Start an XML request for a new page. - if (bbb.xml.endless || endlessLastPage()) // Retrieve pages one at a time for as long as they exist. + if (bbb.flags.endless_xml || endlessLastPage()) // Retrieve pages one at a time for as long as they exist. return; searchPages("endless"); @@ -5264,7 +5260,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. if (blacklistSearch[0]) { var entryHash = blacklistTag.bbbHash(); - var entryDisabled = (blacklistDisabled || (cookies["b" + entryHash] === "1") ? true : false); + var entryDisabled = (blacklistDisabled || (blacklist_session_toggle && cookies["b" + entryHash] === "1") ? true : false); var newEntry = {active: !entryDisabled, tags:blacklistTag, search:blacklistSearch, matches: [], index: i, hash: entryHash}; bbb.blacklist.entries.push(newEntry); @@ -5347,7 +5343,8 @@ function bbbScript() { // This is needed to make this script work in Chrome. if (entry.active) blacklistEntryToggle(i); - createCookie("b" + entry.hash, 0, -1); + if (blacklist_session_toggle) + createCookie("b" + entry.hash, 0, -1); } } @@ -5380,7 +5377,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. if (entry.active) { entry.active = false; - if (!blacklistDisabled) + if (blacklist_session_toggle && !blacklistDisabled) createCookie("b" + entry.hash, 1); for (i = 0, il = links.length; i < il; i++) @@ -5407,7 +5404,8 @@ function bbbScript() { // This is needed to make this script work in Chrome. else { entry.active = true; - createCookie("b" + entry.hash, 0, -1); + if (blacklist_session_toggle) + createCookie("b" + entry.hash, 0, -1); for (i = 0, il = links.length; i < il; i++) links[i].bbbRemoveClass("blacklisted-active"); @@ -6059,12 +6057,12 @@ function bbbScript() { // This is needed to make this script work in Chrome. if (condition) { var conditionType = typeof(condition); - if ((conditionType === "string" && bbb.dialog.flags[condition]) || (conditionType === "function" && condition())) { + if ((conditionType === "string" && bbb.flags[condition]) || (conditionType === "function" && condition())) { nextBbbDialog(); return; } else if (conditionType === "string") - bbb.dialog.flags[condition] = true; + bbb.flags[condition] = true; } // Create the dialog window. From 648bb8b5ba6d8d5fa08630707c2998845db26549 Mon Sep 17 00:00:00 2001 From: Moebius-Strip Date: Mon, 28 Dec 2015 02:16:27 -0500 Subject: [PATCH 18/27] Automatic session storage cleaning * Updated to automatically clear out session storage, with the exception of a few values, in case it happens to get filled during a tab's session. --- better-better-booru.user.js | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/better-better-booru.user.js b/better-better-booru.user.js index b256889..820fc00 100644 --- a/better-better-booru.user.js +++ b/better-better-booru.user.js @@ -140,11 +140,14 @@ function bbbScript() { // This is needed to make this script work in Chrome. } catch (error) { if (error.code === 22 || error.code === 1014) { + var keyName; + var i; + if (this === localStorage) { if (localStorage.length > 2000) { // Try clearing out autocomplete if that appears to be the problem. - for (var i = localStorage.length - 1; i >= 0; i--) { - var keyName = localStorage.key(i); + for (i = localStorage.length - 1; i >= 0; i--) { + keyName = localStorage.key(i); if (keyName.indexOf("ac-") === 0) localStorage.removeItem(keyName); @@ -153,15 +156,29 @@ function bbbScript() { // This is needed to make this script work in Chrome. try { localStorage.setItem(key, value); } - catch (error2) { - bbbNotice("Your settings/data could not be saved. The browser's local storage is full.", -1); + catch (localError) { + bbbNotice("Your settings/data could not be saved/updated. The browser's local storage is full.", -1); } } else - bbbNotice("Your settings/data could not be saved. The browser's local storage is full.", -1); + bbbNotice("Your settings/data could not be saved/updated. The browser's local storage is full.", -1); + } + else { + // Keep only a few values in session storage. + for (i = sessionStorage.length - 1; i >= 0; i--) { + keyName = sessionStorage.key(i); + + if (keyName !== "bbb_endless_default" && keyName !== "bbb_quick_search") + sessionStorage.removeItem(keyName); + } + + try { + sessionStorage.setItem(key, value); + } + catch (sessionError) { + bbbNotice("Your settings/data could not be saved/updated. The browser's session storage is full.", -1); + } } - else - bbbNotice("Your settings/data could not be saved. The browser's session storage is full.", -1); } else bbbNotice("Unexpected error while attempting to save. (Error: " + error.message + ")", -1); From 9f15c40b97b6f10602fbf8cf672464df9c566465 Mon Sep 17 00:00:00 2001 From: Moebius-Strip Date: Sat, 9 Jan 2016 13:49:57 -0500 Subject: [PATCH 19/27] Timestamp reversion * Reverted the timestamp back to the original method since the regular expression wasn't well suited for custom formats and also needed tweaking (lookahead) to completely work on the default format. --- better-better-booru.user.js | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/better-better-booru.user.js b/better-better-booru.user.js index 820fc00..002054a 100644 --- a/better-better-booru.user.js +++ b/better-better-booru.user.js @@ -8901,16 +8901,26 @@ function bbbScript() { // This is needed to make this script work in Chrome. function timestamp(format) { // Returns a simple timestamp based on the format string provided. String placeholders: y = year, m = month, d = day, hh = hours, mm = minutes, ss = seconds + function padDate(number) { + // Adds a leading "0" to single digit values. + var numString = String(number); + + if (numString.length === 1) + numString = "0" + numString; + + return numString; + } + var stamp = format || "y-m-d hh:mm:ss"; var time = new Date(); var year = time.getFullYear(); - var month = time.getMonth() + 1; - var day = time.getDate(); - var hours = time.getHours(); - var minutes = time.getMinutes(); - var seconds = time.getSeconds(); + var month = padDate(time.getMonth() + 1); + var day = padDate(time.getDate()); + var hours = padDate(time.getHours()); + var minutes = padDate(time.getMinutes()); + var seconds = padDate(time.getSeconds()); - stamp = stamp.replace("hh", hours).replace("mm", minutes).replace("ss", seconds).replace("y", year).replace("m", month).replace("d", day).replace(/(^|\D)(\d)($|\D)/g, "$10$2$3"); + stamp = stamp.replace("hh", hours).replace("mm", minutes).replace("ss", seconds).replace("y", year).replace("m", month).replace("d", day); return stamp; } From 23ab39796f558cd8f2183e21c748a1e138174da7 Mon Sep 17 00:00:00 2001 From: Moebius-Strip Date: Sun, 10 Jan 2016 14:02:59 -0500 Subject: [PATCH 20/27] Local storage cleaner * Added a dialog window for cleaning out local storage across the donmai.us domains and subdomains that triggers when saving to local storage fails. The dialog also prevents the script from completely breaking when local storage is full. --- better-better-booru.user.js | 275 +++++++++++++++++++++++++++++++++--- 1 file changed, 253 insertions(+), 22 deletions(-) diff --git a/better-better-booru.user.js b/better-better-booru.user.js index 002054a..1282124 100644 --- a/better-better-booru.user.js +++ b/better-better-booru.user.js @@ -140,33 +140,45 @@ function bbbScript() { // This is needed to make this script work in Chrome. } catch (error) { if (error.code === 22 || error.code === 1014) { - var keyName; - var i; - if (this === localStorage) { - if (localStorage.length > 2000) { - // Try clearing out autocomplete if that appears to be the problem. - for (i = localStorage.length - 1; i >= 0; i--) { - keyName = localStorage.key(i); + if (!bbb.flags.local_storage_full) { + if (localStorage.length > 2000) { + // Try clearing out autocomplete if that appears to be the problem. + cleanLocalStorage("autocomplete"); - if (keyName.indexOf("ac-") === 0) - localStorage.removeItem(keyName); + try { + localStorage.setItem(key, value); + } + catch (localError) { + bbb.flags.local_storage_full = true; + } } - - try { - localStorage.setItem(key, value); + else + bbb.flags.local_storage_full = true; + + // Store the local storage value until it can be retried. + if (bbb.flags.local_storage_full) { + bbb.local_storage_queue = {}; + bbb.local_storage_queue[key] = value; + localStorageDialog(); } - catch (localError) { - bbbNotice("Your settings/data could not be saved/updated. The browser's local storage is full.", -1); + } + else { + // Temporarily store additional local storage values until they can be retried. + if (sessionStorage.getItem("bbb_local_storage_queue")) { + var sessLocal = JSON.parse(sessionStorage.getItem("bbb_local_storage_queue")); + + sessLocal[key] = value; + sessionStorage.bbbSetItem("bbb_local_storage_queue", JSON.stringify(sessLocal)); } + else + bbb.local_storage_queue[key] = value; } - else - bbbNotice("Your settings/data could not be saved/updated. The browser's local storage is full.", -1); } else { // Keep only a few values in session storage. - for (i = sessionStorage.length - 1; i >= 0; i--) { - keyName = sessionStorage.key(i); + for (var i = sessionStorage.length - 1; i >= 0; i--) { + var keyName = sessionStorage.key(i); if (keyName !== "bbb_endless_default" && keyName !== "bbb_quick_search") sessionStorage.removeItem(keyName); @@ -181,7 +193,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. } } else - bbbNotice("Unexpected error while attempting to save. (Error: " + error.message + ")", -1); + bbbNotice("Unexpected error while attempting to save/update settings. (Error: " + error.message + ")", -1); } }; @@ -370,6 +382,8 @@ function bbbScript() { // This is needed to make this script work in Chrome. user: {} // User settings. }; + localStorageCheck(); + loadSettings(); // Load user settings. // Provide a session ID in order to detect XML requests carrying over from other pages. @@ -6797,7 +6811,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. '#bbb-menu .bbb-button {border: 1px solid #CCCCCC; border-radius: 5px; display: inline-block; padding: 5px;}' + '#bbb-menu .bbb-tab {border-top-left-radius: 5px; border-top-right-radius: 5px; display: inline-block; padding: 5px; border: 1px solid #CCCCCC; margin-right: -1px;}' + '#bbb-menu .bbb-active-tab {background-color: #FFFFFF; border-bottom-width: 0px; padding-bottom: 6px;}' + - '#bbb-menu .bbb-header, #bbb-dialog-window .bbb-header {border-bottom: 2px solid #CCCCCC; margin-bottom: 5px; width: 700px;}' + + '#bbb-menu .bbb-header {border-bottom: 2px solid #CCCCCC; margin-bottom: 5px; width: 700px;}' + '#bbb-menu .bbb-toc {list-style-type: upper-roman; margin-left: 30px;}' + '#bbb-menu .bbb-section-options, #bbb-menu .bbb-section-text {margin-bottom: 5px; max-width: 902px;}' + '#bbb-menu .bbb-section-options-left, #bbb-menu .bbb-section-options-right {display: inline-block; vertical-align: top; width: 435px;}' + @@ -6837,7 +6851,8 @@ function bbbScript() { // This is needed to make this script work in Chrome. '#bbb-notice-msg .bbb-notice-msg-entry:last-child {border-bottom: none 0px; margin-bottom: 0px; padding-bottom: 0px;}' + '#bbb-dialog-blocker {display: block; position: fixed; top: 0px; left: 0px; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.33); z-index: 9003; text-align: center;}' + '#bbb-dialog-blocker:before {content: ""; display: inline-block; height: 100%; vertical-align: middle;}' + // Helps vertically center an element with unknown dimensions: https://css-tricks.com/centering-in-the-unknown/ - '#bbb-dialog-window {display: inline-block; display: inline-flex; flex-flow: column; position: relative; background-color: #FFFFFF; border: 10px solid #FFFFFF; outline: 1px solid #CCC; box-shadow: 0px 3px 3px rgba(0, 0, 0, 0.5); color: #000000; max-width: 940px; max-height: 90%; overflow-x: hidden; overflow-y: auto; text-align: left; vertical-align: middle;}' + + '#bbb-dialog-window {display: inline-block; display: inline-flex; flex-flow: column; position: relative; background-color: #FFFFFF; border: 10px solid #FFFFFF; outline: 1px solid #CCC; box-shadow: 0px 3px 3px rgba(0, 0, 0, 0.5); color: #000000; max-width: 940px; max-height: 90%; overflow-x: hidden; overflow-y: auto; text-align: left; vertical-align: middle; line-height: initial;}' + + '#bbb-dialog-window .bbb-header {display: inline-block; clear: both; border-bottom: 2px solid #CCCCCC; margin-bottom: 5px; margin-right: 100px; padding-right: 50px; white-space: nowrap;}' + '#bbb-dialog-window .bbb-dialog-button {border: 1px solid #CCCCCC; border-radius: 5px; display: inline-block; padding: 5px; margin: 0px 5px;}' + '#bbb-dialog-window .bbb-dialog-content-div {padding: 5px; overflow-x: hidden; overflow-y: auto;}' + '#bbb-dialog-window .bbb-dialog-button-div {padding-top: 10px; flex-grow: 0; flex-shrink: 0; overflow: hidden;}' + @@ -8756,8 +8771,224 @@ function bbbScript() { // This is needed to make this script work in Chrome. event.preventDefault(); } + function localStorageDialog() { + // Open a dialog box for cleaning out local storage for donmai.us. + if (getCookie().bbb_ignore_storage) + return; + + var domains = [ + {url: "http://danbooru.donmai.us/", untrusted: false}, + {url: "https://danbooru.donmai.us/", untrusted: false}, + {url: "http://donmai.us/", untrusted: false}, + {url: "https://donmai.us/", untrusted: true}, + {url: "http://sonohara.donmai.us/", untrusted: false}, + {url: "https://sonohara.donmai.us/", untrusted: true}, + {url: "http://hijiribe.donmai.us/", untrusted: false}, + {url: "https://hijiribe.donmai.us/", untrusted: true}, + {url: "http://safebooru.donmai.us/", untrusted: false}, + {url: "https://safebooru.donmai.us/", untrusted: false}, + {url: "http://testbooru.donmai.us/", untrusted: false} + ]; + + var content = document.createDocumentFragment(); + + var header = document.createElement("h2"); + header.innerHTML = "Local Storage Error"; + header.className = "bbb-header"; + content.appendChild(header); + + var introText = document.createElement("div"); + introText.innerHTML = "While trying to save some settings, BBB has detected that your browser's local storage is full for the donmai.us domain and was unable to automatically fix the problem. In order for BBB to function properly, the storage needs to be cleaned out.

BBB can cycle through the various donmai locations and clear out Danbooru's autocomplete cache and BBB's thumbnail info cache for each. Please select the domains/subdomains you'd like to clean from below and click OK to continue. If you click cancel, BBB will ignore the storage problems for the rest of this browsing session, but features may not work as expected.

Notes:
  • Three options in the domain list are not selected by default (marked as untrusted) since they require special permission from the user to accept invalid security certificates. However, if BBB detects you're already on one of these untrusted domains, then it will be automatically selected.
  • If you encounter this warning again right after storage has been cleaned, you may have to check domains you didn't check before or use the \"delete everything\" option to clear items in local storage besides autocomplete and thumbnail info.

Donmai.us domains/subdomains:
"; + content.appendChild(introText); + + var domainDiv = document.createElement("div"); + domainDiv.style.lineHeight = "1.5em"; + content.appendChild(domainDiv); + + var cbFunc = function(event) { + var target = event.target; + + target.nextSibling.style.textDecoration = (target.checked ? "none" : "line-through"); + }; + + for (var i = 0, il = domains.length; i < il; i++) { + var domain = domains[i]; + var isChecked = (!domain.untrusted || location.href.indexOf(domain.url) > -1); + + var listCheckbox = document.createElement("input"); + listCheckbox.name = domain.url; + listCheckbox.type = "checkbox"; + listCheckbox.checked = isChecked; + listCheckbox.style.marginRight = "5px"; + listCheckbox.addEventListener("click", cbFunc, false); + domainDiv.appendChild(listCheckbox); + + var listLink = document.createElement("a"); + listLink.innerHTML = domain.url + (domain.untrusted ? " (untrusted)" : ""); + listLink.href = domain.url; + listLink.target = "_blank"; + listLink.style.textDecoration = (isChecked ? "none" : "line-through"); + domainDiv.appendChild(listLink); + + var br = document.createElement("br"); + domainDiv.appendChild(br); + } + + var optionsText = document.createElement("div"); + optionsText.innerHTML = "Options:
"; + optionsText.style.marginTop = "1em"; + content.appendChild(optionsText); + + var optionsDiv = document.createElement("div"); + optionsDiv.style.lineHeight = "1.5em"; + content.appendChild(optionsDiv); + + var compCheckbox = document.createElement("input"); + compCheckbox.name = "complete-delete"; + compCheckbox.type = "checkbox"; + compCheckbox.style.marginRight = "5px"; + optionsDiv.appendChild(compCheckbox); + + var compText = document.createTextNode("Delete everything in local storage for each selection except for my BBB settings."); + optionsDiv.appendChild(compText); + + var okFunc = function() { + var options = domainDiv.getElementsByTagName("input"); + var mode = (compCheckbox.checked ? "complete" : "normal"); + var selectedURLs = []; + var origURL = location.href; + var nextURL; + var cleanCur = false; + var session = new Date().getTime(); + + for (var i = 0, il = options.length; i < il; i++) { + var option = options[i]; + + if (option.checked) { + if (origURL.indexOf(option.name) === 0) + cleanCur = true; + else if (!nextURL) + nextURL = option.name; + else + selectedURLs.push(encodeURIComponent(option.name)); + } + } + + // Clean the current domain if it was selected. + if (cleanCur) + cleanLocalStorage(mode); + + if (!nextURL) { + // Retry saving if only the current domain was selected and do nothing if no domains were selected. + if (cleanCur) + retryLocalStorage(); + } + else { + // Start cycling through domains. + bbbDialog("Currently cleaning local storage and loading the next domain. Please wait...", {ok: false, important: true}); + sessionStorage.bbbSetItem("bbb_local_storage_queue", JSON.stringify(bbb.local_storage_queue)); + location.href = updateURLQuery(nextURL + "posts/1/", {clean_storage: mode, clean_urls: selectedURLs.join(","), clean_origurl: encodeURIComponent(origURL), clean_session: session}); + } + }; + + var cancelFunc = function() { + createCookie("bbb_ignore_storage", 1); + }; + + bbbDialog(content, {ok: okFunc, cancel: cancelFunc}); + } + + function cleanLocalStorage(mode) { + // Clean out various values in local storage. + var keyName; + var i; + + if (mode === "autocomplete") { + for (i = localStorage.length - 1; i >= 0; i--) { + keyName = localStorage.key(i); + + if (keyName.indexOf("ac-") === 0) + localStorage.removeItem(keyName); + } + } + else if (mode === "normal") { + for (i = localStorage.length - 1; i >= 0; i--) { + keyName = localStorage.key(i); + + if (keyName.indexOf("ac-") === 0 || keyName === "bbb_thumb_cache") + localStorage.removeItem(keyName); + } + } + else if (mode === "complete") { + for (i = localStorage.length - 1; i >= 0; i--) { + keyName = localStorage.key(i); + + if (keyName !== "bbb_settings") + localStorage.removeItem(keyName); + } + } + } + + function retryLocalStorage() { + // Try to save items to local storage that failed to get saved before. + var sessLocal; + + if (sessionStorage.getItem("bbb_local_storage_queue")) { + // Retrieve the local storage values from session storage after cycling through other domains. + sessLocal = JSON.parse(sessionStorage.getItem("bbb_local_storage_queue")); + sessionStorage.removeItem("bbb_local_storage_queue"); + } + else if (bbb.local_storage_queue) { + // If only the BBB storage object exists, assume the user selected to only clean the current domain and reset things. + sessLocal = bbb.local_storage_queue; + delete bbb.local_storage_queue; + delete bbb.flags.local_storage_full; + } + else + return; + + for (var i in sessLocal) { + if (sessLocal.hasOwnProperty(i)) + localStorage.bbbSetItem(i, sessLocal[i]); + } + + bbbNotice("Local storage cleaning has completed.", 6); + } + + function localStorageCheck() { + // Check if the script is currently trying to manage local storage. + var cleanMode = getVar("clean_storage"); + var cleanSession = Number(getVar("clean_session")) || 0; + var session = new Date().getTime(); + + // Stop if the script is not currently cleaning storage or if an old URL is detected. + if (!cleanMode || Math.abs(session - cleanSession) > 60000) + return; + + if (cleanMode !== "save") { + // Cycle through the domains. + var urls = getVar("clean_urls").split(","); + var nextURL = urls.shift(); + var origURL = getVar("clean_origurl"); + + bbb.flags.local_storage_full = true; // Keep the cycled domains from triggering storage problems + bbbDialog("Currently cleaning local storage and loading the next domain. Please wait...", {ok: false, important: true}); + history.replaceState((history.state || {}), "", updateURLQuery(location.href, {clean_storage: undefined, clean_urls: undefined, clean_origurl: undefined, clean_session: undefined})); + cleanLocalStorage(cleanMode); + + if (nextURL) + window.setTimeout(function() { location.href = updateURLQuery(decodeURIComponent(nextURL) + "posts/1/", {clean_storage: cleanMode, clean_urls: urls.join(), clean_origurl: origURL, clean_session: session}); }, 2000); + else + window.setTimeout(function() { location.href = updateURLQuery(decodeURIComponent(origURL), {clean_storage: "save", clean_session: session}); }, 2000); + } + else if (cleanMode === "save") { + history.replaceState((history.state || {}), "", updateURLQuery(location.href, {clean_storage: undefined, clean_session: undefined})); + retryLocalStorage(); + } + } + function getCookie() { - // Return associative array with cookie values. + // Return an associative array with cookie values. var data = document.cookie; if(!data) From 3f344aec6e2e4f88920d1e54f515f516fb5c53e4 Mon Sep 17 00:00:00 2001 From: Moebius-Strip Date: Sun, 10 Jan 2016 14:20:26 -0500 Subject: [PATCH 21/27] Blacklist post display "removed" update * Added CSS rules that will always force thumbnails to be completely hidden when the removed option is selected. The option will no longer depend on Danbooru's CSS. --- better-better-booru.user.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/better-better-booru.user.js b/better-better-booru.user.js index 1282124..63e6db4 100644 --- a/better-better-booru.user.js +++ b/better-better-booru.user.js @@ -7036,7 +7036,9 @@ function bbbScript() { // This is needed to make this script work in Chrome. // Blacklist thumbnail display; if (blacklist_post_display === "removed") { - styles += 'div.post.post-preview.blacklisted {display: block !important;}' + // Comment listing override. + styles += 'article.post-preview.blacklisted {display: inline-block !important;}' + + 'article.post-preview.blacklisted.blacklisted-active {display: none !important;}' + + 'div.post.post-preview.blacklisted {display: block !important;}' + // Comment listing override. 'div.post.post-preview.blacklisted.blacklisted-active {display: none !important;}'; } else if (blacklist_post_display === "hidden") { From 4a290f0dd638a2ae88a6297c41bc9c46877ffd34 Mon Sep 17 00:00:00 2001 From: Moebius-Strip Date: Mon, 11 Jan 2016 00:24:28 -0500 Subject: [PATCH 22/27] Blacklist updates & fixes * Made the blacklist "session toggle" option default to disabled to reflect the change on Danbooru. * Updated the blacklist "post display" option with a separate default option that will make BBB not use any custom blacklist styles and use Danbooru's style instead. * Added some blacklist style rules to the CSS that should disable current and pending Danbooru blacklist style rules when "post display" is not set to default. * Fixed compatibility between the blacklist "post display" hidden option and "thumbnail controls" option in the comments section. --- better-better-booru.user.js | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/better-better-booru.user.js b/better-better-booru.user.js index 63e6db4..8fe29e4 100644 --- a/better-better-booru.user.js +++ b/better-better-booru.user.js @@ -285,9 +285,9 @@ function bbbScript() { // This is needed to make this script work in Chrome. blacklist_add_bars: newOption("checkbox", false, "Additional Bars", "Add a blacklist bar to the comment search listing and individually linked comments so that blacklist entries can be toggled as needed."), blacklist_highlight_color: newOption("text", "#CCCCCC", "Highlight Color", "When using highlighting for \"thumbnail marking\", you may set the color here. NotesLeaving this field blank will result in the default color being used.

For easy color selection, use one of the many free tools on the internet like this one. Hex RGB color codes (#000000, #FFFFFF, etc.) are the recommended values."), blacklist_thumb_controls: newOption("checkbox", false, "Thumbnail Controls", "Allow control over individual blacklisted thumbnails and access to blacklist toggle links from blacklisted thumbnails. DirectionsFor blacklisted thumbnails that have been revealed, hovering over them will reveal a clickable \"X\" icon that can hide them again.

If using the \"hidden\" or \"replaced\" post display options, clicking on the area of a blacklisted thumbnail will pop up a menu that displays what blacklist entries it matches. Clicking the thumbnail area a second time while that menu is open will reveal that single thumbnail.

The menu that pops up on the first click also allows for toggling any listed blacklist entry for the entire page and navigating to the post without revealing its thumbnail. NoteToggling blacklist entries will have no effect on posts that have been changed via their individual controls."), - blacklist_post_display: newOption("dropdown", "removed", "Post Display", "Set how the display of blacklisted posts in thumbnail listings and the comments section is handled. Removed: The default Danbooru behavior where the posts and the space they take up are completely removed. Hidden: Post space is preserved, but thumbnails are hidden. Replaced: Thumbnails are replaced by \"blacklisted\" thumbnail placeholders.", {txtOptions:["Removed (Default):removed", "Hidden:hidden", "Replaced:replaced"]}), + blacklist_post_display: newOption("dropdown", "default", "Post Display", "Set how the display of blacklisted posts in thumbnail listings and the comments section is handled. Default: Danbooru's default method of displaying blacklisted posts. Removed: Posts and the space they take up are completely removed. Hidden: Post space is preserved, but thumbnails are hidden. Replaced: Thumbnails are replaced by \"blacklisted\" thumbnail placeholders.", {txtOptions:["Default:default", "Removed:removed", "Hidden:hidden", "Replaced:replaced"]}), blacklist_smart_view: newOption("checkbox", false, "Smart View", "When navigating to a blacklisted post by using its thumbnail, if the thumbnail has already been revealed, the post content will temporarily be exempt from any blacklist checks for 1 minute and be immediately visible. NoteThumbnails in the parent/child notices of posts with exempt content will still be affected by the blacklist."), - blacklist_session_toggle: newOption("checkbox", true, "Session Toggle", "When toggling an individual blacklist entry on and off, the mode it's toggled to will persist across other pages in the same browsing session until it ends."), + blacklist_session_toggle: newOption("checkbox", false, "Session Toggle", "When toggling an individual blacklist entry on and off, the mode it's toggled to will persist across other pages in the same browsing session until it ends.NoteFor blacklists with many entries, this option can cause unexpected behavior (ex: getting logged out) if too many entries are toggled off at the same time."), blacklist_thumb_mark: newOption("dropdown", "none", "Thumbnail Marking", "Mark the thumbnails of blacklisted posts that have been revealed to make them easier to distinguish from other thumbnails. Highlight: Change the background color of blacklisted thumbnails. Icon Overlay: Add an icon to the lower right corner of blacklisted thumbnails.", {txtOptions:["Disabled:none", "Highlight:highlight", "Icon Overlay:icon"]}), border_spacing: newOption("dropdown", 0, "Border Spacing", "Set the amount of blank space between a border and thumbnail and between a custom tag border and status border. NoteEven when set to 0, status borders and custom tag borders will always have a minimum value of 1 between them. TipUse this option if you often have trouble distinguishing a border from the thumbnail image.", {txtOptions:["0 (Default):0", "1:1", "2:2", "3:3"]}), border_width: newOption("dropdown", 2, "Border Width", "Set the width of thumbnail borders.", {txtOptions:["1:1", "2 (Default):2", "3:3", "4:4", "5:5"]}), @@ -6852,7 +6852,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. '#bbb-dialog-blocker {display: block; position: fixed; top: 0px; left: 0px; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.33); z-index: 9003; text-align: center;}' + '#bbb-dialog-blocker:before {content: ""; display: inline-block; height: 100%; vertical-align: middle;}' + // Helps vertically center an element with unknown dimensions: https://css-tricks.com/centering-in-the-unknown/ '#bbb-dialog-window {display: inline-block; display: inline-flex; flex-flow: column; position: relative; background-color: #FFFFFF; border: 10px solid #FFFFFF; outline: 1px solid #CCC; box-shadow: 0px 3px 3px rgba(0, 0, 0, 0.5); color: #000000; max-width: 940px; max-height: 90%; overflow-x: hidden; overflow-y: auto; text-align: left; vertical-align: middle; line-height: initial;}' + - '#bbb-dialog-window .bbb-header {display: inline-block; clear: both; border-bottom: 2px solid #CCCCCC; margin-bottom: 5px; margin-right: 100px; padding-right: 50px; white-space: nowrap;}' + + '#bbb-dialog-window .bbb-header {border-bottom: 2px solid #CCCCCC; margin-bottom: 5px; margin-right: 100px; padding-right: 50px; white-space: nowrap;}' + '#bbb-dialog-window .bbb-dialog-button {border: 1px solid #CCCCCC; border-radius: 5px; display: inline-block; padding: 5px; margin: 0px 5px;}' + '#bbb-dialog-window .bbb-dialog-content-div {padding: 5px; overflow-x: hidden; overflow-y: auto;}' + '#bbb-dialog-window .bbb-dialog-button-div {padding-top: 10px; flex-grow: 0; flex-shrink: 0; overflow: hidden;}' + @@ -7034,7 +7034,15 @@ function bbbScript() { // This is needed to make this script work in Chrome. '#blacklist-box.bbb-blacklist-box li span {color: #AAAAAA;}'; } - // Blacklist thumbnail display; + // Blacklist thumbnail display. + if (blacklist_post_display !== "default") { + // Override some of Danbooru's CSS for actively blacklisted thumbs. + styles += 'article.post-preview.blacklisted.blacklisted-active, div.post.post-preview.blacklisted.blacklisted-active {filter: none; -webkit-filter: none; -ms-filter: "none";}' + + 'article.post-preview.blacklisted.blacklisted-active:after, div.post.post-preview.blacklisted.blacklisted-active:after {content: none;}' + + 'article.post-preview.blacklisted.blacklisted-active img, div.post.post-preview.blacklisted.blacklisted-active img {display: initial;}' + + 'article.post-preview.blacklisted.blacklisted-active, div.post.post-preview.blacklisted.blacklisted-active {background-color: transparent;}'; + } + if (blacklist_post_display === "removed") { styles += 'article.post-preview.blacklisted {display: inline-block !important;}' + 'article.post-preview.blacklisted.blacklisted-active {display: none !important;}' + @@ -7044,7 +7052,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. else if (blacklist_post_display === "hidden") { styles += 'article.post-preview.blacklisted.blacklisted-active {display: inline-block !important;}' + 'div.post.post-preview.blacklisted {display: block !important;}' + // Comments. - 'article.post-preview.blacklisted.blacklisted-active a.bbb-thumb-link, div.post.post-preview.blacklisted.blacklisted-active div.preview {visibility: hidden !important;}'; + 'article.post-preview.blacklisted.blacklisted-active a.bbb-thumb-link, div.post.post-preview.blacklisted.blacklisted-active div.preview a.bbb-thumb-link {visibility: hidden !important;}'; } else if (blacklist_post_display === "replaced") { styles += 'article.post-preview.blacklisted.blacklisted-active, div.post.post-preview.blacklisted.blacklisted-active {display: inline-block !important; background-position: ' + totalBorderWidth + 'px ' + totalBorderWidth + 'px !important; background-repeat: no-repeat !important; background-image: url(' + bbbBlacklistImg + ') !important;}' + @@ -8127,7 +8135,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. else paginator.parentNode.appendChild(paginatorSpacer); - // Create the css for the fixed paginator separately from the main one since it needs to know what the page's final layout will be with the main css applied. + // Create the CSS for the fixed paginator separately from the main one since it needs to know what the page's final layout will be with the main CSS applied. var style = document.createElement("style"); style.type = "text/css"; style.innerHTML = '.bbb-fixed-paginator div.paginator {position: fixed; padding: 0px; margin: 0px; bottom: 0px; left: 50%; margin-left: ' + paginatorMargAdjust + 'px;}' + From d03d5968cd36778619771561c7f7ef8c1b827d61 Mon Sep 17 00:00:00 2001 From: Moebius-Strip Date: Tue, 12 Jan 2016 22:52:17 -0500 Subject: [PATCH 23/27] Blacklist updates (Custom borders & Thumb info) * Changed the "post display" default option to disabled to simplify things. * Updated the blacklist CSS for better compatibility with Danbooru's default style (hide custom borders). * Updated the "thumbnail info" option so that the info is hidden on blacklisted thumbnails. --- better-better-booru.user.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/better-better-booru.user.js b/better-better-booru.user.js index 8fe29e4..75e1697 100644 --- a/better-better-booru.user.js +++ b/better-better-booru.user.js @@ -285,7 +285,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. blacklist_add_bars: newOption("checkbox", false, "Additional Bars", "Add a blacklist bar to the comment search listing and individually linked comments so that blacklist entries can be toggled as needed."), blacklist_highlight_color: newOption("text", "#CCCCCC", "Highlight Color", "When using highlighting for \"thumbnail marking\", you may set the color here. NotesLeaving this field blank will result in the default color being used.

For easy color selection, use one of the many free tools on the internet like this one. Hex RGB color codes (#000000, #FFFFFF, etc.) are the recommended values."), blacklist_thumb_controls: newOption("checkbox", false, "Thumbnail Controls", "Allow control over individual blacklisted thumbnails and access to blacklist toggle links from blacklisted thumbnails. DirectionsFor blacklisted thumbnails that have been revealed, hovering over them will reveal a clickable \"X\" icon that can hide them again.

If using the \"hidden\" or \"replaced\" post display options, clicking on the area of a blacklisted thumbnail will pop up a menu that displays what blacklist entries it matches. Clicking the thumbnail area a second time while that menu is open will reveal that single thumbnail.

The menu that pops up on the first click also allows for toggling any listed blacklist entry for the entire page and navigating to the post without revealing its thumbnail. NoteToggling blacklist entries will have no effect on posts that have been changed via their individual controls."), - blacklist_post_display: newOption("dropdown", "default", "Post Display", "Set how the display of blacklisted posts in thumbnail listings and the comments section is handled. Default: Danbooru's default method of displaying blacklisted posts. Removed: Posts and the space they take up are completely removed. Hidden: Post space is preserved, but thumbnails are hidden. Replaced: Thumbnails are replaced by \"blacklisted\" thumbnail placeholders.", {txtOptions:["Default:default", "Removed:removed", "Hidden:hidden", "Replaced:replaced"]}), + blacklist_post_display: newOption("dropdown", "disabled", "Post Display", "Set how the display of blacklisted posts in thumbnail listings and the comments section is handled. Removed: Posts and the space they take up are completely removed. Hidden: Post space is preserved, but thumbnails are hidden. Replaced: Thumbnails are replaced by \"blacklisted\" thumbnail placeholders.", {txtOptions:["Disabled:disabled", "Removed:removed", "Hidden:hidden", "Replaced:replaced"]}), blacklist_smart_view: newOption("checkbox", false, "Smart View", "When navigating to a blacklisted post by using its thumbnail, if the thumbnail has already been revealed, the post content will temporarily be exempt from any blacklist checks for 1 minute and be immediately visible. NoteThumbnails in the parent/child notices of posts with exempt content will still be affected by the blacklist."), blacklist_session_toggle: newOption("checkbox", false, "Session Toggle", "When toggling an individual blacklist entry on and off, the mode it's toggled to will persist across other pages in the same browsing session until it ends.NoteFor blacklists with many entries, this option can cause unexpected behavior (ex: getting logged out) if too many entries are toggled off at the same time."), blacklist_thumb_mark: newOption("dropdown", "none", "Thumbnail Marking", "Mark the thumbnails of blacklisted posts that have been revealed to make them easier to distinguish from other thumbnails. Highlight: Change the background color of blacklisted thumbnails. Icon Overlay: Add an icon to the lower right corner of blacklisted thumbnails.", {txtOptions:["Disabled:none", "Highlight:highlight", "Icon Overlay:icon"]}), @@ -6979,14 +6979,16 @@ function bbbScript() { // This is needed to make this script work in Chrome. // Thumbnail info. var thumbInfoStyle = "height: 18px; font-size: 14px; line-height: 18px; text-align: center;"; + if (thumb_info !== "disabled") + styles += '.bbb-thumb-info-parent.blacklisted.blacklisted-active .bbb-thumb-info {display: none;}'; + if (thumb_info === "below") styles += '.bbb-thumb-info-parent .bbb-thumb-info {display: block;' + thumbInfoStyle + '}'; else if (thumb_info === "hover") { styles += '.bbb-thumb-info-parent .bbb-thumb-info {display: none; position: relative; bottom: 18px; background-color: rgba(255, 255, 255, 0.9);' + thumbInfoStyle + '}' + '.bbb-thumb-info-parent:hover .bbb-thumb-info {display: block;}' + '#has-children-relationship-preview article.post-preview.bbb-thumb-info-parent, #has-parent-relationship-preview article.post-preview.bbb-thumb-info-parent {min-width: 130px !important;}' + // Give parent/child notice thumbs a minimum width to prevent element shifting upon hover. - '.bbb-thumb-info-parent:hover .bbb-thumb-info.bbb-thumb-info-short {bottom: 0px;}' + // Short thumbnails get no overlapping. - '.bbb-thumb-info-parent.blacklisted-active .bbb-thumb-info.bbb-thumb-info-short {bottom: 18px;}'; // Actively blacklisted short thumbnails get overlapping. + '.bbb-thumb-info-parent:hover .bbb-thumb-info.bbb-thumb-info-short {bottom: 0px;}'; // Short thumbnails get no overlapping. } // Endless @@ -7035,13 +7037,15 @@ function bbbScript() { // This is needed to make this script work in Chrome. } // Blacklist thumbnail display. - if (blacklist_post_display !== "default") { + if (blacklist_post_display !== "disabled") { // Override some of Danbooru's CSS for actively blacklisted thumbs. styles += 'article.post-preview.blacklisted.blacklisted-active, div.post.post-preview.blacklisted.blacklisted-active {filter: none; -webkit-filter: none; -ms-filter: "none";}' + 'article.post-preview.blacklisted.blacklisted-active:after, div.post.post-preview.blacklisted.blacklisted-active:after {content: none;}' + 'article.post-preview.blacklisted.blacklisted-active img, div.post.post-preview.blacklisted.blacklisted-active img {display: initial;}' + 'article.post-preview.blacklisted.blacklisted-active, div.post.post-preview.blacklisted.blacklisted-active {background-color: transparent;}'; } + else + styles += '.blacklisted.blacklisted-active a.bbb-thumb-link.bbb-custom-tag {border-width: 0px !important;}'; // Hide custom borders for Danbooru's default blacklist style. if (blacklist_post_display === "removed") { styles += 'article.post-preview.blacklisted {display: inline-block !important;}' + @@ -7088,12 +7092,14 @@ function bbbScript() { // This is needed to make this script work in Chrome. 'article.post-preview.blacklisted .bbb-close-circle, div.post.post-preview.blacklisted div.preview .bbb-close-circle {display: none;}'; } + // Move save search to the sidebar. if (move_save_search) { styles += '.bbb-saved-search-item #saved-searches-nav, .bbb-saved-search-item #saved-searches-nav * {background-color: transparent; color: #0073FF; display: inline; font-family: Verdana,Helvetica,sans-serif; line-height: 1.25em; padding: 0px; margin: 0px; border: none;}' + '.bbb-saved-search-item #saved-searches-nav input:hover, .bbb-saved-search-item #saved-searches-nav button:hover {color: #80b9ff;}' + '.bbb-saved-search-item #saved-searches-nav input:focus, .bbb-saved-search-item #saved-searches-nav button:focus {outline: thin dotted;}'; } + // Quick search styles. if (quick_search !== "disabled") { styles += '#bbb-quick-search {position: fixed; top: 0px; right: 0px; z-index: 2001; overflow: auto; padding: 2px; background-color: #FFFFFF; border-bottom: 1px solid #CCCCCC; border-left: 1px solid #CCCCCC; border-bottom-left-radius: 10px;}' + '#bbb-quick-search-form {display: none;}' + From 16aecb7e2993b738d6b4dd41569f0494db2cbef7 Mon Sep 17 00:00:00 2001 From: Moebius-Strip Date: Wed, 13 Jan 2016 12:37:19 -0500 Subject: [PATCH 24/27] Danbooru blacklist custom border fix * Changed single color custom borders to the same style format as multiple color borders to keep the border width from getting unnecessarily set in the style attribute with "!important". --- better-better-booru.user.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/better-better-booru.user.js b/better-better-booru.user.js index 75e1697..6d3a2fe 100644 --- a/better-better-booru.user.js +++ b/better-better-booru.user.js @@ -4336,7 +4336,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. link.bbbAddClass("bbb-custom-tag"); if (secondaryLength === 1 || (single_color_borders && secondaryLength > 1)) - borderStyle = "border: " + border_width + "px " + secondary[0][0] + " " + secondary[0][1] + " !important;"; + borderStyle = "border-color: " + secondary[0][0] + " !important; border-style: " + secondary[0][1] + " !important;"; else if (secondaryLength === 2) borderStyle = "border-color: " + secondary[0][0] + " " + secondary[1][0] + " " + secondary[1][0] + " " + secondary[0][0] + " !important; border-style: " + secondary[0][1] + " " + secondary[1][1] + " " + secondary[1][1] + " " + secondary[0][1] + " !important;"; else if (secondaryLength === 3) @@ -7022,6 +7022,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. '.ui-autocomplete {z-index: 2002 !important;}'; } + // Collapse sidebar sections. if (collapse_sidebar) { styles += '#sidebar ul.bbb-collapsed-sidebar, #sidebar form.bbb-collapsed-sidebar {display: block !important; height: 0px !important; margin: 0px !important; padding: 0px !important; overflow: hidden !important;}' + // Hide the element without changing the display to "none" since that interferes with some of Danbooru's JS. '#sidebar h1, #sidebar h2 {display: inline-block !important;}'; // Inline-block is possible here due to not using display in the previous rule. @@ -9217,4 +9218,4 @@ if (document.body) { } else // Operate normally. bbbScript(); -} \ No newline at end of file +} From 855a9e19df54ecd1eb2f8deaa65d4349ce0b062c Mon Sep 17 00:00:00 2001 From: Moebius-Strip Date: Fri, 15 Jan 2016 01:09:27 -0500 Subject: [PATCH 25/27] Blacklist session toggle option --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 39d9a38..e580769 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ Features * Allows the viewing of hidden/censored tags and automatic control of the number of thumbnails per a page with a basic account or no account. * Endless pages support for various thumbnail listings with several customization options. * Multiple options and features for improved blacklist functionality: + * Session toggle - Make individually disabled blacklist entries persist from page to page. * Post display - Change how blacklisted posts are hidden. * Thumbnail marking - Mark blacklisted thumbnails that have been unhidden so that they are easier to distinguish from other thumbnails. * Thumbnail controls - Allow control over the blacklist from a blacklisted thumbnail and allow for individual control of each blacklisted thumbnail. From db9abe57aa94ddc8e079983af6b2597aa3f03713 Mon Sep 17 00:00:00 2001 From: Moebius-Strip Date: Fri, 15 Jan 2016 01:54:57 -0500 Subject: [PATCH 26/27] Updating the log --- changelog.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/changelog.md b/changelog.md index a502c38..b7fa694 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,20 @@ Changelog ---------- +* Version ?: + * Added a "session toggle" blacklist option for controlling whether individual blacklist entries remain toggled off across pages. + * Updated the "post display" blacklist option with a "disabled" setting to allow the use of Danbooru's default blacklist style and changed "removed" to a standalone setting. + * Updated the "thumbnail info" option so that it is hidden on blacklisted posts. + * Updated to support Danbooru's blacklist style changes. + * Updated to support Danbooru's slider changes for ugoira posts. + * Updated to support Danbooru not looping posts with sound. + * Updated to prevent notes and blacklists from being unnecessarily loaded by Danbooru. + * Fixed loading problems caused by full browser storage. + * Fixed audio issues on video posts with sound. + * Fixed the icon overlay position for animated/video posts. + * Fixed the "search add" option's "toggle" setting not responding to autocomplete selections made by mouse. + * Fixed the "thumbnail controls" blacklist option not working in the comments section when using the "post display" blacklist option's "hidden" setting. + * Fixed instances of tab/window specific settings carrying over to new tabs/windows (endless pages session toggle, quick search pinned status). + * Fixed the timestamp not using leading zeros properly. * Version 7.1: * Added an "additional bars" blacklist option for adding a blacklist bar to thumbnail sections without it. * Updated to support MP4 posts. From cc5b9edff071bb8e42bd14ad0de06c6d518be7b5 Mon Sep 17 00:00:00 2001 From: Moebius-Strip Date: Sat, 16 Jan 2016 15:37:34 -0500 Subject: [PATCH 27/27] Version 7.2 --- better-better-booru.user.js | 5 +++-- changelog.md | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/better-better-booru.user.js b/better-better-booru.user.js index 6d3a2fe..794ef9d 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.1 +// @version 7.2 // @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/* @@ -277,7 +277,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. translation_mode: false }, options: { // Setting options and data. - bbb_version: "7.1", + bbb_version: "7.2", 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"]}), @@ -3045,6 +3045,7 @@ function bbbScript() { // This is needed to make this script work in Chrome. if (bbb.user.thumb_cache_limit > 10000) bbb.user.thumb_cache_limit = 10000; + case "7.1": break; } diff --git a/changelog.md b/changelog.md index b7fa694..077645b 100644 --- a/changelog.md +++ b/changelog.md @@ -1,6 +1,6 @@ Changelog ---------- -* Version ?: +* Version 7.2: * Added a "session toggle" blacklist option for controlling whether individual blacklist entries remain toggled off across pages. * Updated the "post display" blacklist option with a "disabled" setting to allow the use of Danbooru's default blacklist style and changed "removed" to a standalone setting. * Updated the "thumbnail info" option so that it is hidden on blacklisted posts.