@apocaliss92/scrypted-events-recorder 0.0.51 → 0.0.52
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/plugin.zip
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/apocaliss92/scrypted-events-recorder"
|
|
7
7
|
},
|
|
8
|
-
"version": "0.0.
|
|
8
|
+
"version": "0.0.52",
|
|
9
9
|
"scripts": {
|
|
10
10
|
"scrypted-setup-project": "scrypted-setup-project",
|
|
11
11
|
"prescrypted-setup-project": "scrypted-package-json",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@scrypted/common": "file:../scrypted/common",
|
|
45
|
-
"@scrypted/sdk": "
|
|
45
|
+
"@scrypted/sdk": "0.5.55",
|
|
46
46
|
"@types/lodash": "^4.17.14",
|
|
47
47
|
"lodash": "^4.17.21",
|
|
48
48
|
"moment": "^2.30.1"
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// ==UserScript==
|
|
2
|
+
// @name Scrypted - delete button on recorded clip thumbnails
|
|
3
|
+
// @description Adds a small delete button over each RECORDED CLIPS thumbnail on
|
|
4
|
+
// devices using @apocaliss92/scrypted-events-recorder, so you don't
|
|
5
|
+
// have to match filenames in a dropdown by hand.
|
|
6
|
+
// @match https://*/endpoint/@scrypted/core/public/*
|
|
7
|
+
// @grant none
|
|
8
|
+
// @version 1.0
|
|
9
|
+
// ==/UserScript==
|
|
10
|
+
|
|
11
|
+
(function () {
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
14
|
+
// Every clip thumbnail <img> is served by this plugin's own webhook, and its
|
|
15
|
+
// src already contains everything we need (deviceId + filename) as a query
|
|
16
|
+
// param - no need to fetch/match anything separately.
|
|
17
|
+
const THUMB_MARKER = 'videoclipThumbnail?';
|
|
18
|
+
const DELETE_MARKER = 'deleteVideoclip?';
|
|
19
|
+
|
|
20
|
+
// Positions the button over the image's own top-right corner using the
|
|
21
|
+
// image's actual layout box, rather than wrapping the <img> in a new
|
|
22
|
+
// element - the clip card is a flex row (img + text side by side), and
|
|
23
|
+
// wrapping the image breaks that layout.
|
|
24
|
+
function position(btn, img) {
|
|
25
|
+
btn.style.top = (img.offsetTop + 2) + 'px';
|
|
26
|
+
btn.style.left = (img.offsetLeft + img.offsetWidth - 24) + 'px';
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function decorate(img) {
|
|
30
|
+
if (img.dataset.deleteBtnAdded) return;
|
|
31
|
+
img.dataset.deleteBtnAdded = '1';
|
|
32
|
+
|
|
33
|
+
const parent = img.parentElement;
|
|
34
|
+
if (getComputedStyle(parent).position === 'static') {
|
|
35
|
+
parent.style.position = 'relative';
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const btn = document.createElement('button');
|
|
39
|
+
btn.textContent = '\u{1F5D1}'; // 🗑
|
|
40
|
+
btn.title = 'Delete this recorded clip';
|
|
41
|
+
btn.style.cssText = [
|
|
42
|
+
'position:absolute', 'z-index:9999',
|
|
43
|
+
'background:rgba(0,0,0,.65)', 'color:#fff', 'border:none',
|
|
44
|
+
'border-radius:4px', 'width:22px', 'height:22px', 'cursor:pointer',
|
|
45
|
+
'font-size:13px', 'line-height:1', 'padding:0',
|
|
46
|
+
].join(';');
|
|
47
|
+
position(btn, img);
|
|
48
|
+
|
|
49
|
+
btn.addEventListener('click', async (e) => {
|
|
50
|
+
e.preventDefault();
|
|
51
|
+
e.stopPropagation();
|
|
52
|
+
if (!confirm('Delete this recorded clip permanently?')) return;
|
|
53
|
+
|
|
54
|
+
btn.disabled = true;
|
|
55
|
+
btn.textContent = '\u2026'; // …
|
|
56
|
+
try {
|
|
57
|
+
const url = img.src.replace(THUMB_MARKER, DELETE_MARKER);
|
|
58
|
+
const res = await fetch(url);
|
|
59
|
+
if (!res.ok) throw new Error(`${res.status} ${await res.text()}`);
|
|
60
|
+
|
|
61
|
+
parent.remove();
|
|
62
|
+
} catch (err) {
|
|
63
|
+
alert('Failed to delete clip: ' + err.message);
|
|
64
|
+
btn.disabled = false;
|
|
65
|
+
btn.textContent = '\u{1F5D1}';
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
parent.appendChild(btn);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function scan() {
|
|
73
|
+
document
|
|
74
|
+
.querySelectorAll(`img[src*="${THUMB_MARKER}"]`)
|
|
75
|
+
.forEach(decorate);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
new MutationObserver(scan).observe(document.body, { childList: true, subtree: true });
|
|
79
|
+
scan();
|
|
80
|
+
})();
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* mime-db
|
|
3
|
-
* Copyright(c) 2014 Jonathan Ong
|
|
4
|
-
* Copyright(c) 2015-2022 Douglas Christopher Wilson
|
|
5
|
-
* MIT Licensed
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/*!
|
|
9
|
-
* mime-types
|
|
10
|
-
* Copyright(c) 2014 Jonathan Ong
|
|
11
|
-
* Copyright(c) 2015 Douglas Christopher Wilson
|
|
12
|
-
* MIT Licensed
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* @license
|
|
17
|
-
* Lodash <https://lodash.com/>
|
|
18
|
-
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
|
|
19
|
-
* Released under MIT license <https://lodash.com/license>
|
|
20
|
-
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
21
|
-
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
//! moment.js
|
|
25
|
-
|
|
26
|
-
//! moment.js locale configuration
|