-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
86 lines (78 loc) · 2.96 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// LINE送信部分
const send = () => {
const https = require("https")
const querystring = require("querystring")
const Token = "ここにLINENotifyトークン"
const content = querystring.stringify({
message: "adobeCCDeleterでエラーが発生しました。"
})
const options = {
hostname: "notify-api.line.me",
path: "/api/notify",
method: "POST",
headers: {
"Content-type": "application/x-www-form-urlencoded",
"Content-Length": Buffer.byteLength(content),
"Authorization": `Bearer ${Token}`
}
}
const request = https.request(options, res => {
res.setEncoding("utf8")
res.on("data", console.log)
res.on("error", console.log)
})
request.write(content)
request.end()
}
const puppeteer = require("puppeteer");
// 定数 (後述)
const LOGIN_URL = "https://assets.adobe.com/deleted";
const LOGIN_USER = "ここにメールアドレス"; // 使用したいユーザーID
const LOGIN_PASS = "ここにパスワード"; // 使用したいユーザーIDのパスワード
const LOGIN_USER_SELECTOR = "input[type=email]";
const LOGIN_PASS_SELECTOR = "input[type=password]";
const LOGIN_USER_SUBMIT_SELECTOR = "button[data-id=EmailPage-ContinueButton]";
const LOGIN_PASS_SUBMIT_SELECTOR = "button[data-id=PasswordPage-ContinueButton]";
const deleteBtn = "button[data-test-id=CollectionHeader__permanentlyDelete]";
const completeDeleteBtn = ".spectrum-Button--warning";
/**
* メイン処理です。
*/
(async () => {
const browser = await puppeteer.launch({
// ブラウザを開く
headless: false, // ブラウザを表示するか (デバッグの時は false にしたほうが画面が見えてわかりやすいです)
});
const page = await browser.newPage(); // 新規ページ
await page.setViewport({ width: 1440, height: 900 }); // ビューポート (ウィンドウサイズ)
await page.setExtraHTTPHeaders({
// 必要な場合、HTTPヘッダを追加
"Accept-Language": "ja",
});
// ログイン画面でログイン
await page.goto(LOGIN_URL, { waitUntil: "domcontentloaded" });
await page.waitFor(5000);
await page.type(LOGIN_USER_SELECTOR, LOGIN_USER);
await Promise.all([ // ログインボタンクリック
// クリック後ページ遷移後通信が完了するまで待つ (ページによっては 'domcontentloaded' 等でも可)
page.waitForNavigation({ waitUntil: 'networkidle0' }),
page.click(LOGIN_USER_SUBMIT_SELECTOR),
]);
await page.waitFor(2000);
await page.type(LOGIN_PASS_SELECTOR, LOGIN_PASS);
await page.click(LOGIN_PASS_SUBMIT_SELECTOR),
await page.waitFor(10000);
console.log('ロード完了')
for (;;) {
// アイテム選択
await page.click(".spectrum-Checkbox-input")
await page.waitFor(700);
await page.click(deleteBtn)
await page.waitFor(700);
await page.click(completeDeleteBtn)
await page.waitFor(1500);
}
})().catch((e) => {
console.error(e)
send();
});