Skip to content

Commit

Permalink
use exact urls for Gallery.findIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
tophf committed Aug 15, 2024
1 parent 7106cf3 commit 67f66f5
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions script.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -1177,20 +1177,7 @@ const Gallery = {
},

findIndex(gUrl) {
const sel = gUrl.split('#')[1];
if (!sel)
return 0;
let i = +sel;
if (i >= 0 && i === (i | 0))
return i;
for (i = 0; i < ai.gNum; i++) {
const {url} = ai.gItems[i];
if (isArray(url)
? url.indexOf(sel) || url.some(u => u.indexOf(sel, u.lastIndexOf('/')) > 0)
: url === sel || url.indexOf(sel, url.lastIndexOf('/')) > 0
) return i;
}
return 0;
return Math.max(0, ai.gItems.findIndex(({url}) => isArray(url) ? url.includes(gUrl) : url === gUrl));
},

next(dir) {
Expand Down

0 comments on commit 67f66f5

Please sign in to comment.