Skip to content

Commit

Permalink
Merge pull request #45 from pseudonymous/blacklist-bar-fix
Browse files Browse the repository at this point in the history
Version 6.5.3
  • Loading branch information
Moebius-Strip committed Dec 30, 2014
2 parents 3b24ed4 + 9adf82b commit cb8e256
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 67 deletions.
137 changes: 70 additions & 67 deletions better-better-booru.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 6.5.2
// @version 6.5.3
// @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/*
Expand Down Expand Up @@ -63,7 +63,7 @@ function bbbScript() { // This is needed to make this script work in Chrome.
translationMode: false
},
options: { // Setting options and data.
bbb_version: "6.5.2",
bbb_version: "6.5.3",
alternate_image_swap: new Option("checkbox", false, "Alternate Image Swap", "Switch between the sample and original image by clicking the image. Notes can be toggled by using the link in the sidebar options section."),
arrow_nav: new Option("checkbox", false, "Arrow Navigation", "Allow the use of the left and right arrow keys to navigate pages. Has no effect on individual posts."),
autohide_sidebar: new Option("dropdown", "none", "Auto-hide Sidebar", "Hide the sidebar for individual posts, favorites listings, and/or searches until the mouse comes close to the left side of the window or the sidebar gains focus.<br><br><u>Tips</u><br>By using Danbooru's keyboard shortcut for the letter \"Q\" to place focus on the search box, you can unhide the sidebar.<br><br>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"]}),
Expand Down Expand Up @@ -2498,6 +2498,7 @@ function bbbScript() { // This is needed to make this script work in Chrome.
case "6.4":
case "6.5":
case "6.5.1":
case "6.5.2":
break;
}

Expand Down Expand Up @@ -2536,7 +2537,7 @@ function bbbScript() { // This is needed to make this script work in Chrome.
function restoreBackupText() {
// Load the backup text provided into the script.
var textarea = bbb.el.menu.backupTextarea;
var backupString = textarea.value.replace(/\r?\n/g, "").match(/{.+}/);
var backupString = textarea.value.replace(/\r?\n/g, "").match(/\{.+\}/);

if (backupString) {
try {
Expand Down Expand Up @@ -2662,10 +2663,12 @@ function bbbScript() { // This is needed to make this script work in Chrome.
if (!bbb.blacklist.entries.length)
return;

var blacklistBox = document.getElementById("blacklist-box");
var blacklistList = document.getElementById("blacklist-list");
var imgContainer = getId("image-container", target);
// Retrieve the necessary elements from the target element or current document.
var blacklistBox = getId("blacklist-box", target) || document.getElementById("blacklist-box");
var blacklistList = getId("blacklist-list", target) || document.getElementById("blacklist-list");
var imgContainer = getId("image-container", target, "section");
var posts = getPosts(target);

var i, il; // Loop variables.

// Test the image for a match when viewing a post.
Expand Down Expand Up @@ -3558,75 +3561,75 @@ function bbbScript() { // This is needed to make this script work in Chrome.
Danbooru.Ugoira = {};

Danbooru.Ugoira.create_player = function() {
var meta_data = {
mime_type: post.pixiv_ugoira_frame_data.content_type,
frames: post.pixiv_ugoira_frame_data.data
};
var options = {
canvas: document.getElementById("image"),
source: post.file_url,
metadata: meta_data,
chunkSize: 300000,
loop: true,
autoStart: true,
debug: false
};

this.player = new ZipImagePlayer(options);
var meta_data = {
mime_type: post.pixiv_ugoira_frame_data.content_type,
frames: post.pixiv_ugoira_frame_data.data
};
var options = {
canvas: document.getElementById("image"),
source: post.file_url,
metadata: meta_data,
chunkSize: 300000,
loop: true,
autoStart: true,
debug: false
};

this.player = new ZipImagePlayer(options);
};

Danbooru.Ugoira.player = null;

$(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();
}
});
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();
}
});

var player_manually_paused = false;
var player_manually_paused = false;

$("#ugoira-play").click(function(event) {
Danbooru.Ugoira.player.play();
$(this).hide();
$("#ugoira-pause").show();
player_manually_paused = false;
event.preventDefault();
});
$("#ugoira-pause").click(function(event) {
Danbooru.Ugoira.player.pause();
$(this).hide();
$("#ugoira-play").show();
player_manually_paused = true;
event.preventDefault();
});

$("#seek-slider").slider({
min: 0,
max: Danbooru.Ugoira.player._frameCount-1,
start: function() {
// Need to pause while slider is being dragged or playback speed will bug out
Danbooru.Ugoira.player.pause();
},
slide: function(event, ui) {
Danbooru.Ugoira.player._frame = ui.value;
Danbooru.Ugoira.player._displayFrame();
},
stop: function() {
// Resume playback when dragging stops, but only if player was not paused by the user earlier
if (!(player_manually_paused)) {
$("#ugoira-play").click(function(event) {
Danbooru.Ugoira.player.play();
}
}
});
$(Danbooru.Ugoira.player).on("frame", function(frame, frame_number) {
$("#seek-slider").slider("option", "value", frame_number);
});
$(this).hide();
$("#ugoira-pause").show();
player_manually_paused = false;
event.preventDefault();
});
$("#ugoira-pause").click(function(event) {
Danbooru.Ugoira.player.pause();
$(this).hide();
$("#ugoira-play").show();
player_manually_paused = true;
event.preventDefault();
});

$("#seek-slider").slider({
min: 0,
max: Danbooru.Ugoira.player._frameCount-1,
start: function() {
// Need to pause while slider is being dragged or playback speed will bug out
Danbooru.Ugoira.player.pause();
},
slide: function(event, ui) {
Danbooru.Ugoira.player._frame = ui.value;
Danbooru.Ugoira.player._displayFrame();
},
stop: function() {
// Resume playback when dragging stops, but only if player was not paused by the user earlier
if (!(player_manually_paused)) {
Danbooru.Ugoira.player.play();
}
}
});
$(Danbooru.Ugoira.player).on("frame", function(frame, frame_number) {
$("#seek-slider").slider("option", "value", frame_number);
});
});
}
catch (error) {
Expand Down
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
Changelog
----------
* Version 6.5.3:
* Fixed the blacklist section so that it properly updates for hidden images.
* Version 6.5.2:
* Fixed a conflict between the "alternate image swap" option and translation mode.
* Version 6.5.1:
Expand Down

0 comments on commit cb8e256

Please sign in to comment.