Skip to content

Commit e11be29

Browse files
committed
feat: add support for sankakucomplex
1 parent 7fad609 commit e11be29

10 files changed

Lines changed: 1012 additions & 21 deletions

File tree

src/assets/styles/artworkButton.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,8 @@
3737
&.fluid_video {
3838
--pdl-sticky-container-safe-area-bottom: 56px;
3939
}
40+
41+
&.sankaku_video {
42+
--pdl-sticky-container-safe-area-bottom: 80px;
43+
}
4044
}

src/lib/components/Button/artworkButton.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ type ArtworkButtonProps = Omit<ThumbnailBtnProp, 'type'> & {
1111
| 'moebooru_image'
1212
| 'native_video'
1313
| 'vjs_video'
14-
| 'fluid_video';
14+
| 'fluid_video'
15+
| 'sankaku_video';
1516
};
1617

1718
export class ArtworkButton extends HTMLElement {

src/lib/components/Button/thumbnailButton.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export interface ThumbnailBtnProp {
4646
export class ThumbnailButton extends HTMLElement {
4747
private btn?: HTMLButtonElement;
4848
private status: ThumbnailBtnStatus = ThumbnailBtnStatus.Init;
49-
private mediaId: number;
49+
private mediaId: string;
5050
private page?: number;
5151
private type?: ThumbnailBtnType;
5252
private onClick: ThumbnailBtnProp['onClick'];
@@ -56,7 +56,7 @@ export class ThumbnailButton extends HTMLElement {
5656
private progress = 0;
5757
private dirty = false;
5858

59-
#downloadingId: number | null = null;
59+
#downloadingId: string | null = null;
6060
#downloadingPage: number | undefined | null = null;
6161

6262
constructor(props: ThumbnailBtnProp) {
@@ -65,8 +65,8 @@ export class ThumbnailButton extends HTMLElement {
6565
this.onClick = props.onClick;
6666

6767
// modifying `dataset` triggers `attributeChangedCallback`, so we should assign private value before dataset.
68-
this.mediaId = this.toValidatedNumber(props.id);
69-
this.dataset.id = String(this.mediaId);
68+
this.mediaId = String(props.id);
69+
this.dataset.id = this.mediaId;
7070

7171
if (props.type) {
7272
this.dataset.type = this.type = props.type;
@@ -158,15 +158,15 @@ export class ThumbnailButton extends HTMLElement {
158158
try {
159159
if (id === null) throw new Error('Attribute "data-id" is required.');
160160

161-
this.mediaId = this.toValidatedNumber(id);
161+
this.mediaId = id;
162162

163163
this.#resetStatus();
164164
this.#downloadingId && (this.#downloadingId = null);
165165

166166
this.connectedFlag && this.shouldObserveDb && this.observeDb()();
167167
} catch (error) {
168168
logger.error(error);
169-
this.dataset.id = String(this.mediaId);
169+
this.dataset.id = this.mediaId;
170170
}
171171
}
172172

src/lib/db.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type { Readable, Unsubscriber } from 'svelte/store';
55
import { channelEvent } from './channelEvent';
66

77
interface HistoryItemBase {
8-
pid: number;
8+
pid: number | string;
99
userId?: number;
1010
user?: string;
1111
title?: string;
@@ -30,7 +30,7 @@ interface pixivSeasonalEffectItem {
3030
}
3131

3232
interface CacheItem {
33-
pid: number;
33+
pid: number | string;
3434
page: Uint8Array | null;
3535
}
3636

@@ -49,7 +49,7 @@ type DBEventArgsMap = {
4949
};
5050

5151
class HistoryDb extends Dexie {
52-
private history!: Table<HistoryItem, number>;
52+
private history!: Table<HistoryItem, number | string>;
5353
private imageEffect!: Table<pixivSeasonalEffectItem, string>;
5454
private filehandle!: Table<FileSystemDirectoryHandle, string>;
5555
#DIRECTORY_HANDLE_NAME = 'directory-handle';
@@ -63,20 +63,19 @@ class HistoryDb extends Dexie {
6363
});
6464
}
6565

66-
protected throwIfInvalidNumber(num: number | string): number {
67-
if (typeof num === 'string') {
68-
if (num !== '') {
69-
num = +num;
70-
} else {
66+
protected throwIfInvalidNumber(numOrString: number | string): number | string {
67+
if (typeof numOrString === 'string') {
68+
if (numOrString === '') {
7169
return logger.throw('Invalid argument: can not be "".', RangeError);
7270
}
71+
return numOrString;
7372
}
7473

75-
if (num < 0 || !Number.isSafeInteger(num)) {
76-
logger.throw(`Invalid number: ${num}, must be a non-negative integer.`, RangeError);
74+
if (numOrString < 0 || !Number.isSafeInteger(numOrString)) {
75+
logger.throw(`Invalid number: ${numOrString}, must be a non-negative integer.`, RangeError);
7776
}
7877

79-
return num;
78+
return numOrString;
8079
}
8180

8281
public async add(historyData: HistoryData) {

src/main.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { Rule34Vault } from './sites/rule34vault';
1515
import { Rule34Paheal } from './sites/rule34paheal';
1616
import './lib/components/app.tailwind.css';
1717
import { Rule34Us } from './sites/rule34us';
18+
import { SankakuApp } from './sites/sankakuComplex';
1819

1920
// Remove CSS injected into dom in the dev server
2021
if (import.meta.env.DEV) {
@@ -36,7 +37,8 @@ function getSiteInjector() {
3637
Nijie,
3738
Rule34Vault,
3839
Rule34Paheal,
39-
Rule34Us
40+
Rule34Us,
41+
SankakuApp
4042
];
4143
const hostname = location.hostname;
4244

0 commit comments

Comments
 (0)