Make Stuff actually work
This commit is contained in:
parent
ab62e2556a
commit
85dd421d08
1 changed files with 56 additions and 20 deletions
|
|
@ -1,23 +1,59 @@
|
|||
const collection = document.getElementsByClassName("listItem");
|
||||
// ==UserScript==
|
||||
// @name QuickDelete
|
||||
// @namespace https://git.m3.fyi/Marsn3/userscripts
|
||||
// @version 0.1
|
||||
// @author Marsn3
|
||||
// @match https://media.m3.fyi/*
|
||||
// @icon https://www.google.com/s2/favicons?sz=64&domain=tampermonkey.net
|
||||
// @grant none
|
||||
// @run-at document-end
|
||||
// ==/UserScript==
|
||||
|
||||
for (let i = 0; i < collection.length; i++) {
|
||||
let curr = collection[i];
|
||||
let el = document.createElement("button");
|
||||
el.className = "listItemButton paper-icon-button-light emby-button";
|
||||
let el2 = document.createElement("span");
|
||||
el2.className = "material-icons delete";
|
||||
el2.style.color = "red";
|
||||
el.appendChild(el2);
|
||||
el.onclick = function () {
|
||||
(function () {
|
||||
"use strict";
|
||||
var username = "mars";
|
||||
var password = "absw3712mcS";
|
||||
var apiKey = "38346c399d57454da3bdbf47ba716765";
|
||||
var userid = "e55a6ca076a14cb5a6ca9cfaa75498c1";
|
||||
function insert() {
|
||||
const baseURL = window.origin;
|
||||
fetch(`${baseURL}/Users/${userid}/Authenticate/?pw=${password}`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"X-Emby-Authorization": `MediaBrowser Client="QuickDelete", Device="Chrome", DeviceId="test", Version="10.8.9", Token="${apiKey}"`,
|
||||
},
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then((data) => (apiKey = data.AccessToken));
|
||||
|
||||
const collection = document.getElementsByClassName("listItem");
|
||||
for (let i = 0; i < collection.length; i++) {
|
||||
let curr = collection[i];
|
||||
let el = document.createElement("button");
|
||||
el.className = "listItemButton paper-icon-button-light emby-button";
|
||||
let el2 = document.createElement("span");
|
||||
el2.className = "material-icons delete";
|
||||
el2.style.color = "red";
|
||||
el.appendChild(el2);
|
||||
el.onclick = function () {
|
||||
let url = "https://media.m3.fyi/Items/" + this.parentElement.dataset.id;
|
||||
console.log("Deleting" + url);
|
||||
fetch(url,
|
||||
{
|
||||
method: "DELETE",
|
||||
headers: {
|
||||
"X-Emby-Authorization": 'MediaBrowser Client="QuickDelete", Device="Chrome", DeviceId="test", Version="10.8.9", Token="38346c399d57454da3bdbf47ba716765"'
|
||||
}
|
||||
})
|
||||
console.log(`Deleting ${url}`);
|
||||
fetch(url, {
|
||||
method: "DELETE",
|
||||
headers: {
|
||||
"X-Emby-Authorization": `MediaBrowser Client="QuickDelete", Device="Chrome", DeviceId="test", Version="10.8.9", Token="${apiKey}"`,
|
||||
},
|
||||
});
|
||||
this.parentElement.remove();
|
||||
};
|
||||
curr.appendChild(el);
|
||||
}
|
||||
curr.appendChild(el);
|
||||
}
|
||||
}
|
||||
function onKeydown(evt) {
|
||||
// Use https://keycode.info/ to get keys
|
||||
if (evt.altKey && evt.keyCode == 81) {
|
||||
insert();
|
||||
}
|
||||
}
|
||||
document.addEventListener("keydown", onKeydown, true);
|
||||
})();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue