@skrillex1224/chrome-article-publish-extension 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/index.d.ts +4 -10
- package/dist/adapters/index.js +1 -1
- package/dist/{chunk-TKRBESSS.js → chunk-6KMYIRZU.js} +161 -249
- package/dist/chunk-6KMYIRZU.js.map +1 -0
- package/dist/{chunk-CBRXLVZK.js → chunk-DTCVBBPG.js} +32 -1
- package/dist/chunk-DTCVBBPG.js.map +1 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/{interface-DHk2PdyN.d.ts → interface-CLQqUboy.d.ts} +23 -1
- package/dist/runtime/index.d.ts +4 -3
- package/dist/runtime/index.js +1 -1
- package/dist/{types-GigbrW8J.d.ts → types-CTtvGuEx.d.ts} +1 -1
- package/package.json +5 -4
- package/dist/chunk-CBRXLVZK.js.map +0 -1
- package/dist/chunk-TKRBESSS.js.map +0 -1
package/dist/adapters/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { P as PlatformAdapter, a as PublishOptions, A as AdapterRegistryEntry, b as PreprocessConfig } from '../types-
|
|
2
|
-
export { C as Category, D as DEFAULT_PREPROCESS_CONFIG, c as Draft, I as ImageProgressCallback, O as OutputFormat } from '../types-
|
|
3
|
-
import { P as PlatformMeta, R as RuntimeInterface, A as AuthResult, a as Article, S as SyncResult, c as PublishStatusRef, d as PublishStatusResult, H as HeaderRule } from '../interface-
|
|
1
|
+
import { P as PlatformAdapter, a as PublishOptions, A as AdapterRegistryEntry, b as PreprocessConfig } from '../types-CTtvGuEx.js';
|
|
2
|
+
export { C as Category, D as DEFAULT_PREPROCESS_CONFIG, c as Draft, I as ImageProgressCallback, O as OutputFormat } from '../types-CTtvGuEx.js';
|
|
3
|
+
import { P as PlatformMeta, R as RuntimeInterface, A as AuthResult, a as Article, S as SyncResult, c as PublishStatusRef, d as PublishStatusResult, H as HeaderRule } from '../interface-CLQqUboy.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* 适配器基类
|
|
@@ -461,7 +461,6 @@ declare class CSDNAdapter extends CodeAdapter {
|
|
|
461
461
|
private preserveTaskListMarkers;
|
|
462
462
|
private postSaveArticle;
|
|
463
463
|
private postSaveArticleFromPage;
|
|
464
|
-
private getCsdnTab;
|
|
465
464
|
publish(article: Article, options?: PublishOptions): Promise<SyncResult>;
|
|
466
465
|
getStatus(statusRef: PublishStatusRef): Promise<PublishStatusResult>;
|
|
467
466
|
private findManagedArticle;
|
|
@@ -614,8 +613,7 @@ declare class DouyinAdapter extends CodeAdapter {
|
|
|
614
613
|
private getCreatorJsonFromPage;
|
|
615
614
|
private postCreatorForm;
|
|
616
615
|
private postCreatorFormFromPage;
|
|
617
|
-
private
|
|
618
|
-
private closeCreatorTab;
|
|
616
|
+
private withCreatorTab;
|
|
619
617
|
private extractUserData;
|
|
620
618
|
private isSuccessResponse;
|
|
621
619
|
private buildTextPayload;
|
|
@@ -667,7 +665,6 @@ declare class BaijiahaoAdapter extends CodeAdapter {
|
|
|
667
665
|
private mapArticleStatus;
|
|
668
666
|
private isPublishedItem;
|
|
669
667
|
private resolvePublishedPublicUrl;
|
|
670
|
-
private getPublishedPageTab;
|
|
671
668
|
private readPublishedPageSnapshot;
|
|
672
669
|
private urlMatchesArticleId;
|
|
673
670
|
private sleep;
|
|
@@ -805,13 +802,11 @@ declare class ToutiaoAdapter extends CodeAdapter {
|
|
|
805
802
|
protected uploadImageByUrl(src: string): Promise<ImageUploadResult>;
|
|
806
803
|
private getCsrfToken;
|
|
807
804
|
private publishInPage;
|
|
808
|
-
private ensureToutiaoTab;
|
|
809
805
|
private findManagedArticle;
|
|
810
806
|
private extractList;
|
|
811
807
|
private parseManagedRow;
|
|
812
808
|
private itemMatches;
|
|
813
809
|
private mapManagedStatus;
|
|
814
|
-
private ensureToutiaoManageTab;
|
|
815
810
|
private getVisitedUserId;
|
|
816
811
|
private buildManagedListUrl;
|
|
817
812
|
private resolvePostUrl;
|
|
@@ -846,7 +841,6 @@ declare class TencentAdapter extends CodeAdapter {
|
|
|
846
841
|
private uploadImageFileByUrl;
|
|
847
842
|
private prepareArticleContent;
|
|
848
843
|
private callPublishService;
|
|
849
|
-
private ensureTencentTab;
|
|
850
844
|
private buildArticleListUrl;
|
|
851
845
|
private hasListData;
|
|
852
846
|
private extractUserInfo;
|
package/dist/adapters/index.js
CHANGED
|
@@ -1036,13 +1036,19 @@ var BaijiahaoAdapter = class extends CodeAdapter {
|
|
|
1036
1036
|
return status === "publish" || String(item.is_published) === "1" || item.dxxFinalAuditResult === "publish" || item.secure_status === "publish" || item.quality_status === "publish";
|
|
1037
1037
|
}
|
|
1038
1038
|
async resolvePublishedPublicUrl(articleId) {
|
|
1039
|
-
if (!articleId || !this.runtime.tabs?.
|
|
1039
|
+
if (!articleId || !this.runtime.tabs?.withManagedTab || !this.runtime.tabs?.executeScript) {
|
|
1040
1040
|
return void 0;
|
|
1041
1041
|
}
|
|
1042
1042
|
const pageUrl = `https://baijiahao.baidu.com/s?id=${encodeURIComponent(articleId)}`;
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1043
|
+
return this.runtime.tabs.withManagedTab({
|
|
1044
|
+
urlPattern: "*://baijiahao.baidu.com/*",
|
|
1045
|
+
createUrl: pageUrl,
|
|
1046
|
+
active: false,
|
|
1047
|
+
match: (tab) => Boolean(tab.url && this.urlMatchesArticleId(tab.url, articleId))
|
|
1048
|
+
}, async (tab) => {
|
|
1049
|
+
if (tab.owned) {
|
|
1050
|
+
await this.sleep(1e3);
|
|
1051
|
+
}
|
|
1046
1052
|
for (let attempt = 0; attempt < 3; attempt++) {
|
|
1047
1053
|
const snapshot = await this.readPublishedPageSnapshot(tab.id, articleId);
|
|
1048
1054
|
if (snapshot?.matchesArticle) {
|
|
@@ -1051,27 +1057,7 @@ var BaijiahaoAdapter = class extends CodeAdapter {
|
|
|
1051
1057
|
await this.sleep(1e3);
|
|
1052
1058
|
}
|
|
1053
1059
|
return void 0;
|
|
1054
|
-
}
|
|
1055
|
-
if (tab.owned) {
|
|
1056
|
-
await this.runtime.tabs?.close(tab.id).catch((error) => {
|
|
1057
|
-
logger3.debug("Baijiahao temporary tab close failed:", error);
|
|
1058
|
-
});
|
|
1059
|
-
}
|
|
1060
|
-
}
|
|
1061
|
-
}
|
|
1062
|
-
async getPublishedPageTab(articleId, pageUrl) {
|
|
1063
|
-
const tabs = await this.runtime.tabs?.query("*://baijiahao.baidu.com/*");
|
|
1064
|
-
const existing = tabs?.find((tab2) => tab2.url && this.urlMatchesArticleId(tab2.url, articleId));
|
|
1065
|
-
if (existing?.id) return { id: existing.id, owned: false };
|
|
1066
|
-
const tab = await this.runtime.tabs?.create(pageUrl, false);
|
|
1067
|
-
if (!tab?.id) return null;
|
|
1068
|
-
if (this.runtime.tabs?.waitForLoad) {
|
|
1069
|
-
await this.runtime.tabs.waitForLoad(tab.id, 3e4).catch((error) => {
|
|
1070
|
-
logger3.debug("Baijiahao public page load wait failed:", error);
|
|
1071
|
-
});
|
|
1072
|
-
}
|
|
1073
|
-
await this.sleep(1e3);
|
|
1074
|
-
return { id: tab.id, owned: true };
|
|
1060
|
+
});
|
|
1075
1061
|
}
|
|
1076
1062
|
async readPublishedPageSnapshot(tabId, articleId) {
|
|
1077
1063
|
try {
|
|
@@ -2765,13 +2751,16 @@ var CSDNAdapter = class extends CodeAdapter {
|
|
|
2765
2751
|
return response.text();
|
|
2766
2752
|
}
|
|
2767
2753
|
async postSaveArticleFromPage(apiPath, headers, payload) {
|
|
2768
|
-
|
|
2754
|
+
const tabs = this.runtime.tabs;
|
|
2755
|
+
if (!tabs?.withManagedTab || !tabs.executeScript) {
|
|
2769
2756
|
return null;
|
|
2770
2757
|
}
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2758
|
+
return tabs.withManagedTab({
|
|
2759
|
+
urlPattern: ["*://mp.csdn.net/*", "*://editor.csdn.net/*"],
|
|
2760
|
+
createUrl: "https://mp.csdn.net/mp_blog/creation/editor",
|
|
2761
|
+
active: false
|
|
2762
|
+
}, async (tab) => {
|
|
2763
|
+
const result = await tabs.executeScript(
|
|
2775
2764
|
tab.id,
|
|
2776
2765
|
async (requestUrl, requestHeaders, requestPayload) => {
|
|
2777
2766
|
const response = await fetch(requestUrl, {
|
|
@@ -2793,29 +2782,7 @@ var CSDNAdapter = class extends CodeAdapter {
|
|
|
2793
2782
|
throw new Error(`CSDN \u53D1\u5E03\u63A5\u53E3\u8BF7\u6C42\u5931\u8D25: HTTP ${result.status} ${result.text.slice(0, 200)}`);
|
|
2794
2783
|
}
|
|
2795
2784
|
return result.text;
|
|
2796
|
-
}
|
|
2797
|
-
if (tab.owned) {
|
|
2798
|
-
await this.runtime.tabs?.close(tab.id).catch((error) => {
|
|
2799
|
-
logger6.debug("CSDN temporary tab close failed:", error);
|
|
2800
|
-
});
|
|
2801
|
-
}
|
|
2802
|
-
}
|
|
2803
|
-
}
|
|
2804
|
-
async getCsdnTab() {
|
|
2805
|
-
const patterns = ["*://mp.csdn.net/*", "*://editor.csdn.net/*"];
|
|
2806
|
-
for (const pattern of patterns) {
|
|
2807
|
-
const tabs = await this.runtime.tabs?.query(pattern);
|
|
2808
|
-
const tab2 = tabs?.find((item) => typeof item.id === "number");
|
|
2809
|
-
if (tab2?.id) return { id: tab2.id, owned: false };
|
|
2810
|
-
}
|
|
2811
|
-
if (!this.runtime.tabs?.create) return null;
|
|
2812
|
-
const tab = await this.runtime.tabs.create("https://mp.csdn.net/mp_blog/creation/editor", false);
|
|
2813
|
-
if (this.runtime.tabs.waitForLoad) {
|
|
2814
|
-
await this.runtime.tabs.waitForLoad(tab.id, 3e4).catch((error) => {
|
|
2815
|
-
logger6.debug("CSDN tab load wait failed:", error);
|
|
2816
|
-
});
|
|
2817
|
-
}
|
|
2818
|
-
return { id: tab.id, owned: true };
|
|
2785
|
+
});
|
|
2819
2786
|
}
|
|
2820
2787
|
async publish(article, options) {
|
|
2821
2788
|
return this.withHeaderRules(this.HEADER_RULES, async () => {
|
|
@@ -3733,15 +3700,11 @@ async function uploadDouyinVideo(article, context) {
|
|
|
3733
3700
|
if (!userId) {
|
|
3734
3701
|
throw new Error("\u6296\u97F3\u89C6\u9891\u4E0A\u4F20\u5931\u8D25: \u672A\u83B7\u53D6\u5230\u7528\u6237 ID");
|
|
3735
3702
|
}
|
|
3736
|
-
if (!context.runtime.tabs?.
|
|
3703
|
+
if (!context.runtime.tabs?.executeScript) {
|
|
3737
3704
|
throw new Error("\u5F53\u524D\u8FD0\u884C\u65F6\u4E0D\u652F\u6301\u6296\u97F3\u5B98\u65B9\u4E0A\u4F20\u5668\uFF0C\u8BF7\u5728\u6D4F\u89C8\u5668\u6269\u5C55\u73AF\u5883\u4E2D\u53D1\u5E03\u89C6\u9891");
|
|
3738
3705
|
}
|
|
3739
|
-
const
|
|
3740
|
-
|
|
3741
|
-
throw new Error("\u672A\u627E\u5230\u6296\u97F3\u521B\u4F5C\u8005\u4E2D\u5FC3\u9875\u9762\uFF0C\u65E0\u6CD5\u6267\u884C\u5B98\u65B9\u4E0A\u4F20\u5668");
|
|
3742
|
-
}
|
|
3743
|
-
try {
|
|
3744
|
-
return await context.runtime.tabs.executeScript(
|
|
3706
|
+
const uploaded = await context.withCreatorTab(async (tab) => {
|
|
3707
|
+
return context.runtime.tabs.executeScript(
|
|
3745
3708
|
tab.id,
|
|
3746
3709
|
async (video, currentUserId) => {
|
|
3747
3710
|
function getOfficialUploader() {
|
|
@@ -3838,11 +3801,11 @@ async function uploadDouyinVideo(article, context) {
|
|
|
3838
3801
|
},
|
|
3839
3802
|
[{ ...article.video, url: videoUrl }, userId]
|
|
3840
3803
|
);
|
|
3841
|
-
}
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
}
|
|
3804
|
+
});
|
|
3805
|
+
if (!uploaded) {
|
|
3806
|
+
throw new Error("\u672A\u627E\u5230\u6296\u97F3\u521B\u4F5C\u8005\u4E2D\u5FC3\u9875\u9762\uFF0C\u65E0\u6CD5\u6267\u884C\u5B98\u65B9\u4E0A\u4F20\u5668");
|
|
3845
3807
|
}
|
|
3808
|
+
return uploaded;
|
|
3846
3809
|
}
|
|
3847
3810
|
async function waitForVideoTransend(videoId, context) {
|
|
3848
3811
|
await context.getCreatorJsonFromPage(
|
|
@@ -4022,7 +3985,7 @@ var DouyinAdapter = class extends CodeAdapter {
|
|
|
4022
3985
|
postCreatorJson: (url, body, options) => this.postCreatorJson(url, body, options),
|
|
4023
3986
|
postCreatorForm: (url, body, options) => this.postCreatorForm(url, body, options),
|
|
4024
3987
|
getCreatorJsonFromPage: (url) => this.getCreatorJsonFromPage(url),
|
|
4025
|
-
|
|
3988
|
+
withCreatorTab: (callback) => this.withCreatorTab(callback),
|
|
4026
3989
|
assertPublishSuccess: (response) => this.assertPublishSuccess(response),
|
|
4027
3990
|
extractPublishPostId: (response) => this.extractPublishPostId(response),
|
|
4028
3991
|
createResult: (success, data) => this.createResult(success, data),
|
|
@@ -4309,66 +4272,59 @@ var DouyinAdapter = class extends CodeAdapter {
|
|
|
4309
4272
|
return this.parseJsonText(text);
|
|
4310
4273
|
}
|
|
4311
4274
|
async postCreatorJsonFromPage(url, body) {
|
|
4312
|
-
if (!this.runtime.tabs?.
|
|
4313
|
-
return null;
|
|
4314
|
-
}
|
|
4315
|
-
const tab = await this.getCreatorTab();
|
|
4316
|
-
if (!tab) {
|
|
4275
|
+
if (!this.runtime.tabs?.withManagedTab || !this.runtime.tabs?.executeScript) {
|
|
4317
4276
|
return null;
|
|
4318
4277
|
}
|
|
4319
|
-
|
|
4320
|
-
|
|
4321
|
-
|
|
4322
|
-
|
|
4323
|
-
|
|
4324
|
-
|
|
4325
|
-
|
|
4326
|
-
|
|
4327
|
-
|
|
4328
|
-
|
|
4329
|
-
|
|
4330
|
-
|
|
4331
|
-
|
|
4332
|
-
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
|
|
4336
|
-
|
|
4337
|
-
|
|
4338
|
-
|
|
4339
|
-
|
|
4340
|
-
|
|
4341
|
-
|
|
4342
|
-
if (
|
|
4343
|
-
|
|
4278
|
+
return this.withCreatorTab(async (tab) => {
|
|
4279
|
+
try {
|
|
4280
|
+
const result = await this.runtime.tabs.executeScript(
|
|
4281
|
+
tab.id,
|
|
4282
|
+
async (requestUrl, requestBody) => {
|
|
4283
|
+
const response = await fetch(requestUrl, {
|
|
4284
|
+
method: "POST",
|
|
4285
|
+
credentials: "include",
|
|
4286
|
+
headers: {
|
|
4287
|
+
"Content-Type": "application/json",
|
|
4288
|
+
Accept: "application/json, text/plain, */*"
|
|
4289
|
+
},
|
|
4290
|
+
body: JSON.stringify(requestBody)
|
|
4291
|
+
});
|
|
4292
|
+
return {
|
|
4293
|
+
ok: response.ok,
|
|
4294
|
+
status: response.status,
|
|
4295
|
+
statusText: response.statusText,
|
|
4296
|
+
text: await response.text()
|
|
4297
|
+
};
|
|
4298
|
+
},
|
|
4299
|
+
[url, body]
|
|
4300
|
+
);
|
|
4301
|
+
if (!result.ok) {
|
|
4302
|
+
if (this.looksLikeSecondVerify(result.text) || result.status === 401 || result.status === 403) {
|
|
4303
|
+
throw new Error("\u6296\u97F3\u8981\u6C42\u4E8C\u6B21\u9A8C\u8BC1\uFF0C\u8BF7\u5728\u521B\u4F5C\u8005\u4E2D\u5FC3\u5B8C\u6210\u5B89\u5168\u9A8C\u8BC1\u540E\u91CD\u8BD5");
|
|
4304
|
+
}
|
|
4305
|
+
throw new Error(`\u6296\u97F3\u9875\u9762\u4E0A\u4E0B\u6587\u8BF7\u6C42\u5931\u8D25: HTTP ${result.status} ${result.text.slice(0, 200)}`);
|
|
4344
4306
|
}
|
|
4345
|
-
|
|
4346
|
-
}
|
|
4347
|
-
|
|
4348
|
-
|
|
4349
|
-
|
|
4350
|
-
|
|
4351
|
-
|
|
4307
|
+
return this.parseJsonText(result.text);
|
|
4308
|
+
} catch (error) {
|
|
4309
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
4310
|
+
if (this.looksLikeSecondVerify(message)) {
|
|
4311
|
+
throw error;
|
|
4312
|
+
}
|
|
4313
|
+
logger7.debug("Creator page request failed, falling back to extension fetch:", error);
|
|
4314
|
+
return null;
|
|
4352
4315
|
}
|
|
4353
|
-
|
|
4354
|
-
return null;
|
|
4355
|
-
} finally {
|
|
4356
|
-
await this.closeCreatorTab(tab);
|
|
4357
|
-
}
|
|
4316
|
+
});
|
|
4358
4317
|
}
|
|
4359
4318
|
async getCreatorJsonFromPage(url) {
|
|
4360
|
-
|
|
4319
|
+
const tabs = this.runtime.tabs;
|
|
4320
|
+
if (!tabs?.withManagedTab || !tabs.executeScript) {
|
|
4361
4321
|
throw new Error("\u5F53\u524D\u8FD0\u884C\u65F6\u4E0D\u652F\u6301\u6296\u97F3\u9875\u9762\u4E0A\u4E0B\u6587\u8BF7\u6C42\uFF0C\u8BF7\u5728\u6D4F\u89C8\u5668\u6269\u5C55\u73AF\u5883\u4E2D\u53D1\u5E03");
|
|
4362
4322
|
}
|
|
4363
|
-
const
|
|
4364
|
-
|
|
4365
|
-
throw new Error("\u672A\u627E\u5230\u6296\u97F3\u521B\u4F5C\u8005\u4E2D\u5FC3\u9875\u9762\uFF0C\u65E0\u6CD5\u6267\u884C\u9875\u9762\u4E0A\u4E0B\u6587\u8BF7\u6C42");
|
|
4366
|
-
}
|
|
4367
|
-
try {
|
|
4368
|
-
const result = await this.runtime.tabs.executeScript(
|
|
4323
|
+
const response = await this.withCreatorTab(async (tab) => {
|
|
4324
|
+
const result = await tabs.executeScript(
|
|
4369
4325
|
tab.id,
|
|
4370
4326
|
async (requestUrl) => {
|
|
4371
|
-
const
|
|
4327
|
+
const response2 = await fetch(requestUrl, {
|
|
4372
4328
|
method: "GET",
|
|
4373
4329
|
credentials: "include",
|
|
4374
4330
|
headers: {
|
|
@@ -4376,10 +4332,10 @@ var DouyinAdapter = class extends CodeAdapter {
|
|
|
4376
4332
|
}
|
|
4377
4333
|
});
|
|
4378
4334
|
return {
|
|
4379
|
-
ok:
|
|
4380
|
-
status:
|
|
4381
|
-
statusText:
|
|
4382
|
-
text: await
|
|
4335
|
+
ok: response2.ok,
|
|
4336
|
+
status: response2.status,
|
|
4337
|
+
statusText: response2.statusText,
|
|
4338
|
+
text: await response2.text()
|
|
4383
4339
|
};
|
|
4384
4340
|
},
|
|
4385
4341
|
[url]
|
|
@@ -4391,9 +4347,11 @@ var DouyinAdapter = class extends CodeAdapter {
|
|
|
4391
4347
|
throw new Error(`\u6296\u97F3\u9875\u9762\u4E0A\u4E0B\u6587\u8BF7\u6C42\u5931\u8D25: HTTP ${result.status} ${result.text.slice(0, 200)}`);
|
|
4392
4348
|
}
|
|
4393
4349
|
return this.parseJsonText(result.text);
|
|
4394
|
-
}
|
|
4395
|
-
|
|
4350
|
+
});
|
|
4351
|
+
if (response === null) {
|
|
4352
|
+
throw new Error("\u672A\u627E\u5230\u6296\u97F3\u521B\u4F5C\u8005\u4E2D\u5FC3\u9875\u9762\uFF0C\u65E0\u6CD5\u6267\u884C\u9875\u9762\u4E0A\u4E0B\u6587\u8BF7\u6C42");
|
|
4396
4353
|
}
|
|
4354
|
+
return response;
|
|
4397
4355
|
}
|
|
4398
4356
|
async postCreatorForm(url, body, options) {
|
|
4399
4357
|
if (options?.preferPageContext) {
|
|
@@ -4419,75 +4377,58 @@ var DouyinAdapter = class extends CodeAdapter {
|
|
|
4419
4377
|
return this.parseJsonText(text);
|
|
4420
4378
|
}
|
|
4421
4379
|
async postCreatorFormFromPage(url, body) {
|
|
4422
|
-
if (!this.runtime.tabs?.
|
|
4423
|
-
return null;
|
|
4424
|
-
}
|
|
4425
|
-
const tab = await this.getCreatorTab();
|
|
4426
|
-
if (!tab) {
|
|
4380
|
+
if (!this.runtime.tabs?.withManagedTab || !this.runtime.tabs?.executeScript) {
|
|
4427
4381
|
return null;
|
|
4428
4382
|
}
|
|
4429
|
-
|
|
4430
|
-
|
|
4431
|
-
|
|
4432
|
-
|
|
4433
|
-
|
|
4434
|
-
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
|
|
4443
|
-
|
|
4444
|
-
|
|
4445
|
-
|
|
4446
|
-
|
|
4447
|
-
|
|
4448
|
-
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
if (
|
|
4453
|
-
|
|
4383
|
+
return this.withCreatorTab(async (tab) => {
|
|
4384
|
+
try {
|
|
4385
|
+
const result = await this.runtime.tabs.executeScript(
|
|
4386
|
+
tab.id,
|
|
4387
|
+
async (requestUrl, requestBody) => {
|
|
4388
|
+
const response = await fetch(requestUrl, {
|
|
4389
|
+
method: "POST",
|
|
4390
|
+
credentials: "include",
|
|
4391
|
+
headers: {
|
|
4392
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
4393
|
+
Accept: "application/json, text/plain, */*"
|
|
4394
|
+
},
|
|
4395
|
+
body: new URLSearchParams(requestBody)
|
|
4396
|
+
});
|
|
4397
|
+
return {
|
|
4398
|
+
ok: response.ok,
|
|
4399
|
+
status: response.status,
|
|
4400
|
+
statusText: response.statusText,
|
|
4401
|
+
text: await response.text()
|
|
4402
|
+
};
|
|
4403
|
+
},
|
|
4404
|
+
[url, body]
|
|
4405
|
+
);
|
|
4406
|
+
if (!result.ok) {
|
|
4407
|
+
if (this.looksLikeSecondVerify(result.text) || result.status === 401 || result.status === 403) {
|
|
4408
|
+
throw new Error("\u6296\u97F3\u8981\u6C42\u4E8C\u6B21\u9A8C\u8BC1\uFF0C\u8BF7\u5728\u521B\u4F5C\u8005\u4E2D\u5FC3\u5B8C\u6210\u5B89\u5168\u9A8C\u8BC1\u540E\u91CD\u8BD5");
|
|
4409
|
+
}
|
|
4410
|
+
throw new Error(`\u6296\u97F3\u9875\u9762\u4E0A\u4E0B\u6587\u8BF7\u6C42\u5931\u8D25: HTTP ${result.status} ${result.text.slice(0, 200)}`);
|
|
4454
4411
|
}
|
|
4455
|
-
|
|
4456
|
-
}
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
|
|
4460
|
-
|
|
4461
|
-
|
|
4412
|
+
return this.parseJsonText(result.text);
|
|
4413
|
+
} catch (error) {
|
|
4414
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
4415
|
+
if (this.looksLikeSecondVerify(message)) {
|
|
4416
|
+
throw error;
|
|
4417
|
+
}
|
|
4418
|
+
logger7.debug("Creator page form request failed, falling back to extension fetch:", error);
|
|
4419
|
+
return null;
|
|
4462
4420
|
}
|
|
4463
|
-
|
|
4464
|
-
return null;
|
|
4465
|
-
} finally {
|
|
4466
|
-
await this.closeCreatorTab(tab);
|
|
4467
|
-
}
|
|
4421
|
+
});
|
|
4468
4422
|
}
|
|
4469
|
-
async
|
|
4470
|
-
|
|
4471
|
-
const existingTab = existingTabs?.find((tab2) => typeof tab2.id === "number");
|
|
4472
|
-
if (existingTab?.id) {
|
|
4473
|
-
return { id: existingTab.id, owned: false };
|
|
4474
|
-
}
|
|
4475
|
-
if (!this.runtime.tabs?.create) {
|
|
4423
|
+
async withCreatorTab(callback) {
|
|
4424
|
+
if (!this.runtime.tabs?.withManagedTab) {
|
|
4476
4425
|
return null;
|
|
4477
4426
|
}
|
|
4478
|
-
|
|
4479
|
-
|
|
4480
|
-
|
|
4481
|
-
|
|
4482
|
-
|
|
4483
|
-
}
|
|
4484
|
-
return { id: tab.id, owned: true };
|
|
4485
|
-
}
|
|
4486
|
-
async closeCreatorTab(tab) {
|
|
4487
|
-
if (!tab.owned) return;
|
|
4488
|
-
await this.runtime.tabs?.close(tab.id).catch((error) => {
|
|
4489
|
-
logger7.debug("Creator temporary tab close failed:", error);
|
|
4490
|
-
});
|
|
4427
|
+
return this.runtime.tabs.withManagedTab({
|
|
4428
|
+
urlPattern: "*://creator.douyin.com/*",
|
|
4429
|
+
createUrl: `${CREATOR_ORIGIN}/creator-micro/home`,
|
|
4430
|
+
active: false
|
|
4431
|
+
}, callback);
|
|
4491
4432
|
}
|
|
4492
4433
|
extractUserData(response) {
|
|
4493
4434
|
const data = response.data || response;
|
|
@@ -6246,8 +6187,14 @@ var TencentAdapter = class extends CodeAdapter {
|
|
|
6246
6187
|
};
|
|
6247
6188
|
}
|
|
6248
6189
|
async callPublishService(method, payload) {
|
|
6249
|
-
|
|
6250
|
-
|
|
6190
|
+
if (!this.runtime.tabs?.withManagedTab) {
|
|
6191
|
+
throw new Error("\u5F53\u524D runtime \u4E0D\u652F\u6301\u9875\u9762\u4E0A\u4E0B\u6587\u8BF7\u6C42");
|
|
6192
|
+
}
|
|
6193
|
+
return this.runtime.tabs.withManagedTab({
|
|
6194
|
+
urlPattern: "*://om.qq.com/*",
|
|
6195
|
+
createUrl: this.meta.homepage,
|
|
6196
|
+
active: false
|
|
6197
|
+
}, async (tab) => {
|
|
6251
6198
|
const result = await this.runtime.tabs.executeScript(tab.id, async (serviceMethod, requestPayload) => {
|
|
6252
6199
|
try {
|
|
6253
6200
|
let req;
|
|
@@ -6267,23 +6214,7 @@ var TencentAdapter = class extends CodeAdapter {
|
|
|
6267
6214
|
throw new Error(result.error || "\u817E\u8BAF\u53F7\u9875\u9762\u4E0A\u4E0B\u6587\u8BF7\u6C42\u5931\u8D25");
|
|
6268
6215
|
}
|
|
6269
6216
|
return result.data;
|
|
6270
|
-
}
|
|
6271
|
-
if (tab.owned) {
|
|
6272
|
-
await this.runtime.tabs?.close(tab.id).catch((error) => {
|
|
6273
|
-
logger11.debug("Tencent temporary tab close failed:", error);
|
|
6274
|
-
});
|
|
6275
|
-
}
|
|
6276
|
-
}
|
|
6277
|
-
}
|
|
6278
|
-
async ensureTencentTab() {
|
|
6279
|
-
if (!this.runtime.tabs) {
|
|
6280
|
-
throw new Error("\u5F53\u524D runtime \u4E0D\u652F\u6301\u9875\u9762\u4E0A\u4E0B\u6587\u8BF7\u6C42");
|
|
6281
|
-
}
|
|
6282
|
-
const existing = await this.runtime.tabs.query("*://om.qq.com/*");
|
|
6283
|
-
if (existing[0]?.id) return { id: existing[0].id, owned: false };
|
|
6284
|
-
const tab = await this.runtime.tabs.create(this.meta.homepage, false);
|
|
6285
|
-
await this.runtime.tabs.waitForLoad(tab.id, 3e4);
|
|
6286
|
-
return { id: tab.id, owned: true };
|
|
6217
|
+
});
|
|
6287
6218
|
}
|
|
6288
6219
|
buildArticleListUrl(page) {
|
|
6289
6220
|
const url = new URL("https://om.qq.com/marticle/article/list");
|
|
@@ -6550,8 +6481,14 @@ var ToutiaoAdapter = class extends CodeAdapter {
|
|
|
6550
6481
|
return token.includes(",") ? token.split(",")[1] || token : token;
|
|
6551
6482
|
}
|
|
6552
6483
|
async publishInPage(url, body) {
|
|
6553
|
-
|
|
6554
|
-
|
|
6484
|
+
if (!this.runtime.tabs?.withManagedTab) {
|
|
6485
|
+
throw new Error("\u5F53\u524D runtime \u4E0D\u652F\u6301\u9875\u9762\u4E0A\u4E0B\u6587\u8BF7\u6C42");
|
|
6486
|
+
}
|
|
6487
|
+
return this.runtime.tabs.withManagedTab({
|
|
6488
|
+
urlPattern: "*://mp.toutiao.com/*",
|
|
6489
|
+
createUrl: this.meta.homepage,
|
|
6490
|
+
active: false
|
|
6491
|
+
}, async (tab) => {
|
|
6555
6492
|
const result = await this.runtime.tabs.executeScript(tab.id, async (fetchUrl, fetchBody) => {
|
|
6556
6493
|
try {
|
|
6557
6494
|
const response = await fetch(fetchUrl, {
|
|
@@ -6571,27 +6508,17 @@ var ToutiaoAdapter = class extends CodeAdapter {
|
|
|
6571
6508
|
throw new Error(result.error || "\u4ECA\u65E5\u5934\u6761\u9875\u9762\u4E0A\u4E0B\u6587\u53D1\u5E03\u8BF7\u6C42\u5931\u8D25");
|
|
6572
6509
|
}
|
|
6573
6510
|
return result.data;
|
|
6574
|
-
}
|
|
6575
|
-
if (tab.owned) {
|
|
6576
|
-
await this.runtime.tabs?.close(tab.id).catch((error) => {
|
|
6577
|
-
logger12.debug("Toutiao temporary publish tab close failed:", error);
|
|
6578
|
-
});
|
|
6579
|
-
}
|
|
6580
|
-
}
|
|
6511
|
+
});
|
|
6581
6512
|
}
|
|
6582
|
-
async
|
|
6583
|
-
if (!this.runtime.tabs) {
|
|
6513
|
+
async findManagedArticle(id, title) {
|
|
6514
|
+
if (!this.runtime.tabs?.withManagedTab) {
|
|
6584
6515
|
throw new Error("\u5F53\u524D runtime \u4E0D\u652F\u6301\u9875\u9762\u4E0A\u4E0B\u6587\u8BF7\u6C42");
|
|
6585
6516
|
}
|
|
6586
|
-
|
|
6587
|
-
|
|
6588
|
-
|
|
6589
|
-
|
|
6590
|
-
|
|
6591
|
-
}
|
|
6592
|
-
async findManagedArticle(id, title) {
|
|
6593
|
-
const tab = await this.ensureToutiaoManageTab();
|
|
6594
|
-
try {
|
|
6517
|
+
return this.runtime.tabs.withManagedTab({
|
|
6518
|
+
urlPattern: "*://mp.toutiao.com/profile_v4/manage/content/all*",
|
|
6519
|
+
createUrl: "https://mp.toutiao.com/profile_v4/manage/content/all",
|
|
6520
|
+
active: false
|
|
6521
|
+
}, async (tab) => {
|
|
6595
6522
|
const userId = await this.getVisitedUserId(tab.id);
|
|
6596
6523
|
const pages = [1, 2, 3];
|
|
6597
6524
|
for (const page of pages) {
|
|
@@ -6611,13 +6538,7 @@ var ToutiaoAdapter = class extends CodeAdapter {
|
|
|
6611
6538
|
if (match) return match;
|
|
6612
6539
|
}
|
|
6613
6540
|
return null;
|
|
6614
|
-
}
|
|
6615
|
-
if (tab.owned) {
|
|
6616
|
-
await this.runtime.tabs?.close(tab.id).catch((error) => {
|
|
6617
|
-
logger12.debug("Toutiao temporary manage tab close failed:", error);
|
|
6618
|
-
});
|
|
6619
|
-
}
|
|
6620
|
-
}
|
|
6541
|
+
});
|
|
6621
6542
|
}
|
|
6622
6543
|
extractList(res) {
|
|
6623
6544
|
if (Array.isArray(res.data)) return res.data.map((item) => this.parseManagedRow(item)).filter(Boolean);
|
|
@@ -6705,16 +6626,6 @@ var ToutiaoAdapter = class extends CodeAdapter {
|
|
|
6705
6626
|
checkedAt
|
|
6706
6627
|
};
|
|
6707
6628
|
}
|
|
6708
|
-
async ensureToutiaoManageTab() {
|
|
6709
|
-
if (!this.runtime.tabs) {
|
|
6710
|
-
throw new Error("\u5F53\u524D runtime \u4E0D\u652F\u6301\u9875\u9762\u4E0A\u4E0B\u6587\u8BF7\u6C42");
|
|
6711
|
-
}
|
|
6712
|
-
const existing = await this.runtime.tabs.query("*://mp.toutiao.com/profile_v4/manage/content/all*");
|
|
6713
|
-
if (existing[0]?.id) return { id: existing[0].id, owned: false };
|
|
6714
|
-
const tab = await this.runtime.tabs.create("https://mp.toutiao.com/profile_v4/manage/content/all", false);
|
|
6715
|
-
await this.runtime.tabs.waitForLoad(tab.id, 3e4);
|
|
6716
|
-
return { id: tab.id, owned: true };
|
|
6717
|
-
}
|
|
6718
6629
|
async getVisitedUserId(tabId) {
|
|
6719
6630
|
try {
|
|
6720
6631
|
const id = await this.runtime.tabs.executeScript(tabId, () => {
|
|
@@ -7316,7 +7227,7 @@ var WeixinAdapter = class extends CodeAdapter {
|
|
|
7316
7227
|
async loadSafePublishCode(data, options) {
|
|
7317
7228
|
const strategyInfo = this.parseStrategyInfo(data.strategy_info);
|
|
7318
7229
|
if (!this.needsSafeScan(strategyInfo)) return {};
|
|
7319
|
-
if (!this.runtime.tabs?.
|
|
7230
|
+
if (!this.runtime.tabs?.withManagedTab) {
|
|
7320
7231
|
throw new Error("\u5FAE\u4FE1\u516C\u4F17\u53F7\u53D1\u5E03\u9700\u8981\u5FAE\u4FE1\u5B89\u5168\u626B\u7801\u9A8C\u8BC1\uFF0C\u4F46\u5F53\u524D\u8FD0\u884C\u65F6\u4E0D\u80FD\u6253\u5F00\u9A8C\u8BC1\u4E8C\u7EF4\u7801");
|
|
7321
7232
|
}
|
|
7322
7233
|
const token = this.weixinMeta.token;
|
|
@@ -7340,6 +7251,7 @@ var WeixinAdapter = class extends CodeAdapter {
|
|
|
7340
7251
|
if (!qrRes.uuid) {
|
|
7341
7252
|
throw new Error(this.formatStageError("\u5B89\u5168\u9A8C\u8BC1", qrRes));
|
|
7342
7253
|
}
|
|
7254
|
+
const safeUuid = qrRes.uuid;
|
|
7343
7255
|
const msgId = String(data.operation_seq || ticketRes.operation_seq || "");
|
|
7344
7256
|
const qrUrl = new URL("https://mp.weixin.qq.com/safe/safeqrcode");
|
|
7345
7257
|
qrUrl.searchParams.set("ticket", ticketRes.ticket);
|
|
@@ -7358,14 +7270,14 @@ var WeixinAdapter = class extends CodeAdapter {
|
|
|
7358
7270
|
method: "qrcode",
|
|
7359
7271
|
expiresAt
|
|
7360
7272
|
});
|
|
7361
|
-
|
|
7362
|
-
|
|
7363
|
-
|
|
7364
|
-
|
|
7365
|
-
|
|
7366
|
-
|
|
7367
|
-
}
|
|
7368
|
-
}
|
|
7273
|
+
return this.runtime.tabs.withManagedTab({
|
|
7274
|
+
urlPattern: "*://mp.weixin.qq.com/safe/safeqrcode*",
|
|
7275
|
+
createUrl: qrUrl.toString(),
|
|
7276
|
+
active: true,
|
|
7277
|
+
match: (tab) => tab.url === qrUrl.toString()
|
|
7278
|
+
}, async () => {
|
|
7279
|
+
return { code: await this.pollSafeUuid(safeUuid, expiresAt), isNeedCode: "1" };
|
|
7280
|
+
});
|
|
7369
7281
|
}
|
|
7370
7282
|
async pollSafeUuid(uuid, timeoutAt = Date.now() + 18e4) {
|
|
7371
7283
|
const token = this.weixinMeta.token;
|
|
@@ -7828,4 +7740,4 @@ export {
|
|
|
7828
7740
|
ToutiaoAdapter,
|
|
7829
7741
|
WeixinAdapter
|
|
7830
7742
|
};
|
|
7831
|
-
//# sourceMappingURL=chunk-
|
|
7743
|
+
//# sourceMappingURL=chunk-6KMYIRZU.js.map
|