9b395f5cc3
E2E Headed Chrome / e2e-headed (macos-15) (push) Has been cancelled
E2E Headed Chrome / e2e-headed (ubuntu-latest) (push) Has been cancelled
E2E Headed Chrome / e2e-headed (windows-latest) (push) Has been cancelled
CI / build (macos-latest) (push) Has been cancelled
CI / build (ubuntu-latest) (push) Has been cancelled
CI / build (windows-latest) (push) Has been cancelled
CI / unit-test (push) Has been cancelled
CI / bun-test (push) Has been cancelled
CI / adapter-test (push) Has been cancelled
CI / smoke-test (macos-latest) (push) Has been cancelled
CI / smoke-test (ubuntu-latest) (push) Has been cancelled
Security Audit / audit (push) Has been cancelled
Build Chrome Extension / build (push) Has been cancelled
Trigger Website Rebuild (Docs Updated) / dispatch (push) Has been cancelled
61 lines
1.9 KiB
JavaScript
61 lines
1.9 KiB
JavaScript
import { cli, Strategy } from '@jackwener/opencli/registry';
|
|
cli({
|
|
site: 'pixiv',
|
|
name: 'ranking',
|
|
access: 'read',
|
|
description: 'Pixiv illustration rankings (daily/weekly/monthly)',
|
|
domain: 'www.pixiv.net',
|
|
strategy: Strategy.COOKIE,
|
|
browser: true,
|
|
args: [
|
|
{
|
|
name: 'mode',
|
|
default: 'daily',
|
|
help: 'Ranking mode',
|
|
choices: [
|
|
'daily',
|
|
'weekly',
|
|
'monthly',
|
|
'rookie',
|
|
'original',
|
|
'male',
|
|
'female',
|
|
'daily_r18',
|
|
'weekly_r18',
|
|
],
|
|
},
|
|
{ name: 'page', type: 'int', default: 1, help: 'Page number' },
|
|
{ name: 'limit', type: 'int', default: 20, help: 'Number of results' },
|
|
],
|
|
columns: ['rank', 'title', 'author', 'user_id', 'illust_id', 'pages', 'bookmarks', 'url'],
|
|
pipeline: [
|
|
{ navigate: 'https://www.pixiv.net' },
|
|
{ evaluate: `(async () => {
|
|
const mode = \${{ args.mode | json }};
|
|
const page = \${{ args.page | json }};
|
|
const limit = \${{ args.limit | json }};
|
|
const res = await fetch(
|
|
'https://www.pixiv.net/ranking.php?mode=' + mode + '&p=' + page + '&format=json',
|
|
{ credentials: 'include' }
|
|
);
|
|
if (!res.ok) {
|
|
if (res.status === 401 || res.status === 403) throw new Error('Authentication required — please log in to Pixiv in Chrome');
|
|
throw new Error('Pixiv request failed (HTTP ' + res.status + ')');
|
|
}
|
|
const data = await res.json();
|
|
const items = (data?.contents || []).slice(0, limit);
|
|
return items.map((item, i) => ({
|
|
rank: item.rank,
|
|
title: item.title,
|
|
author: item.user_name,
|
|
user_id: item.user_id,
|
|
illust_id: item.illust_id,
|
|
pages: item.illust_page_count,
|
|
bookmarks: item.illust_bookmark_count,
|
|
url: 'https://www.pixiv.net/artworks/' + item.illust_id
|
|
}));
|
|
})()
|
|
` },
|
|
],
|
|
});
|