devtools-propeller 0.0.0-stage → 1.0.0
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/README.md +37 -2
- package/auto.js +3 -0
- package/index.js +60 -0
- package/package.json +23 -4
package/README.md
CHANGED
|
@@ -1,3 +1,38 @@
|
|
|
1
|
-
#
|
|
1
|
+
# devtools-propeller
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
ブラウザーの開発者ツールでプロペラAAを回すジョークパッケージです。Elements(要素)パネルを開くと、`<html>` のすぐ上の HTML コメントに表示されます。
|
|
4
|
+
|
|
5
|
+
## デモ
|
|
6
|
+
|
|
7
|
+
[demo.html](https://raw.githubusercontent.com/H4M4CHi-ttr/devtools-propeller/main/demo.html) を保存してブラウザーで開き、F12 で Elements(要素)パネルを表示してください。
|
|
8
|
+
|
|
9
|
+
## インストール
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npm install devtools-propeller
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## 回し方
|
|
16
|
+
|
|
17
|
+
ページを開いたときに回すには、ブラウザー向けのエントリーファイルに次の1行を追加します。
|
|
18
|
+
|
|
19
|
+
```js
|
|
20
|
+
import "devtools-propeller/auto";
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
開始と終了を自分で決めたい場合は、ブラウザー側で次のように使います。通常のエントリーポイントは関数の呼び出しを待ちます。
|
|
24
|
+
|
|
25
|
+
```js
|
|
26
|
+
import { startPropeller } from "devtools-propeller";
|
|
27
|
+
|
|
28
|
+
const stop = startPropeller();
|
|
29
|
+
|
|
30
|
+
// 片付けるとき
|
|
31
|
+
stop();
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## ページへの影響
|
|
35
|
+
|
|
36
|
+
依存パッケージは0件です。動作中は、同じコメント1個の内容を80ミリ秒ごとに更新します。非表示のタブではタイマーを休止し、`stop()` を呼ぶとコメント、タイマー、表示状態を監視するイベントリスナーを片付けます。ページ全体を監視する `MutationObserver` には、監視設定に応じてコメントの追加・更新・削除が通知されます。
|
|
37
|
+
|
|
38
|
+
アニメーションは開発者ツールの Elements(要素)パネルで確認できます。
|
package/auto.js
ADDED
package/index.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
const pose = "\ ( ‘ᾥ’ )/ \n \ \\n";
|
|
2
|
+
|
|
3
|
+
const blades = [
|
|
4
|
+
[
|
|
5
|
+
" \ γ∩ミ",
|
|
6
|
+
" ⊂:: ::⊃))",
|
|
7
|
+
" /乂∪彡\",
|
|
8
|
+
],
|
|
9
|
+
[
|
|
10
|
+
" \ ⊂╲ ノ",
|
|
11
|
+
" ヾ:: ::ミ",
|
|
12
|
+
" /ノ ╲\⊃",
|
|
13
|
+
],
|
|
14
|
+
[
|
|
15
|
+
" \ ∩彡",
|
|
16
|
+
" ((⊂: :⊃",
|
|
17
|
+
" / ミ∪ \",
|
|
18
|
+
],
|
|
19
|
+
[
|
|
20
|
+
" \ ヽ ╱⊃",
|
|
21
|
+
" ミ:: ::ノ",
|
|
22
|
+
" /⊂╱ \",
|
|
23
|
+
],
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
const frames = blades.map((rows) => "\n" + pose + rows.join("\n") + "\n");
|
|
27
|
+
let stopActive;
|
|
28
|
+
|
|
29
|
+
/** Start the propeller in the document tree. Call the returned function to remove it. */
|
|
30
|
+
export function startPropeller() {
|
|
31
|
+
if (stopActive) return stopActive;
|
|
32
|
+
|
|
33
|
+
let frame = 0;
|
|
34
|
+
let timer;
|
|
35
|
+
const comment = document.createComment(frames[frame]);
|
|
36
|
+
document.insertBefore(comment, document.documentElement);
|
|
37
|
+
|
|
38
|
+
function tick() {
|
|
39
|
+
frame = (frame + 1) % frames.length;
|
|
40
|
+
comment.data = frames[frame];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function syncVisibility() {
|
|
44
|
+
clearInterval(timer);
|
|
45
|
+
if (!document.hidden) timer = setInterval(tick, 80);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function stop() {
|
|
49
|
+
if (stopActive !== stop) return;
|
|
50
|
+
clearInterval(timer);
|
|
51
|
+
document.removeEventListener("visibilitychange", syncVisibility);
|
|
52
|
+
comment.remove();
|
|
53
|
+
stopActive = undefined;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
stopActive = stop;
|
|
57
|
+
document.addEventListener("visibilitychange", syncVisibility);
|
|
58
|
+
syncVisibility();
|
|
59
|
+
return stop;
|
|
60
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "devtools-propeller",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "開発者ツールのHTMLコメントでプロペラAAを回すジョークパッケージ",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": "./index.js",
|
|
8
|
+
"./auto": "./auto.js"
|
|
9
|
+
},
|
|
10
|
+
"sideEffects": [
|
|
11
|
+
"./auto.js"
|
|
12
|
+
],
|
|
13
|
+
"files": [
|
|
14
|
+
"index.js",
|
|
15
|
+
"auto.js"
|
|
16
|
+
],
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/H4M4CHi-ttr/devtools-propeller.git"
|
|
20
|
+
},
|
|
21
|
+
"bugs": {
|
|
22
|
+
"url": "https://github.com/H4M4CHi-ttr/devtools-propeller/issues"
|
|
23
|
+
},
|
|
24
|
+
"homepage": "https://github.com/H4M4CHi-ttr/devtools-propeller#readme"
|
|
25
|
+
}
|