Skip to content

Commit ec3ee25

Browse files
committed
Store userscript controls in generic container
1 parent 20cf02a commit ec3ee25

File tree

1 file changed

+46
-28
lines changed

1 file changed

+46
-28
lines changed

delete-applications.user.js

Lines changed: 46 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ For installation instructions, see https://scpwiki.com/usertools
66

77
/* CHANGELOG
88
9-
v1.3.0
9+
v1.3.1 (2024-10-10)
10+
- Userscript controls are now stored in a generic container available to other userscripts.
11+
12+
v1.3.0 (2023-09-08)
1013
- Added changelog.
1114
- Removed extra commas from the confirmation popup when deleting applications from more than one site.
1215
- Deletes now execute in batches of 100 separated by a short delay to bypass Wikidot's single-request limit of 996.
@@ -367,6 +370,46 @@ async function nextPage(messageElement) {
367370
}
368371

369372
;(function () {
373+
// Set up container for userscript controls, unless another userscript already did
374+
let scriptControlContainer = document.getElementById("messages-userscripts")
375+
if (!scriptControlContainer) {
376+
scriptControlContainer = document.createElement("div")
377+
scriptControlContainer.id = "messages-userscripts"
378+
scriptControlContainer.style.display = "flex"
379+
scriptControlContainer.style.justifyContent = "end"
380+
scriptControlContainer.style.flexWrap = "wrap"
381+
scriptControlContainer.style.marginBlock = "1.5rem"
382+
scriptControlContainer.style.gap = "1.5rem"
383+
384+
document
385+
.getElementById("message-area")
386+
.parentElement.prepend(scriptControlContainer)
387+
}
388+
389+
const deleteButtonsContainer = document.createElement("div")
390+
deleteButtonsContainer.id = "delete-applications-controls"
391+
deleteButtonsContainer.style.border = "thin solid lightgrey"
392+
deleteButtonsContainer.style.borderRadius = "0.5rem"
393+
deleteButtonsContainer.style.display = shouldShowDeleteButtons()
394+
? "flex"
395+
: "none"
396+
deleteButtonsContainer.style.flexDirection = "column"
397+
deleteButtonsContainer.style.maxWidth = "max-content"
398+
deleteButtonsContainer.style.padding = "1rem 1rem 0"
399+
deleteButtonsContainer.innerHTML = `
400+
<p style="font-size: smaller">
401+
<a href="https://scpwiki.com/usertools#delete-applications">Delete applications</a> by ${supportUser()}
402+
</p>
403+
<p id="delete-applications-buttons" style="
404+
display: flex;
405+
flex-direction: row;
406+
flex-wrap: wrap;
407+
gap: 0.5rem;
408+
"></p>
409+
`
410+
411+
scriptControlContainer.appendChild(deleteButtonsContainer)
412+
370413
// Create the buttons
371414
const deleteRecentButton = document.createElement("button")
372415
deleteRecentButton.innerText = "Delete recent applications"
@@ -390,33 +433,8 @@ async function nextPage(messageElement) {
390433
.trim()
391434
deleteAllButton.addEventListener("click", () => deleteApplications(true))
392435

393-
const deleteButtonsContainer = document.createElement("div")
394-
deleteButtonsContainer.style.border = "thin solid lightgrey"
395-
deleteButtonsContainer.style.borderRadius = "0.5rem"
396-
deleteButtonsContainer.style.display = shouldShowDeleteButtons()
397-
? "flex"
398-
: "none"
399-
deleteButtonsContainer.style.flexDirection = "column"
400-
deleteButtonsContainer.style.maxWidth = "max-content"
401-
deleteButtonsContainer.style.padding = "1rem 1rem 0"
402-
deleteButtonsContainer.style.margin = "1.5rem 0 1.5rem auto"
403-
deleteButtonsContainer.innerHTML = `
404-
<p style="font-size: smaller">
405-
<a href="https://scpwiki.com/usertools#delete-applications">Delete applications userscript</a> by ${supportUser()}
406-
</p>
407-
<p id="delete-buttons" style="
408-
display: flex;
409-
flex-direction: row;
410-
flex-wrap: wrap;
411-
gap: 0.5rem;
412-
"></p>
413-
`
414-
415-
document
416-
.getElementById("message-area")
417-
.parentElement.prepend(deleteButtonsContainer)
418-
document
419-
.getElementById("delete-buttons")
436+
deleteButtonsContainer
437+
.querySelector("#delete-applications-buttons")
420438
.append(deleteRecentButton, deleteAllButton)
421439

422440
// Detect clicks to messages and inbox tabs and hide/show buttons as appropriate

0 commit comments

Comments
 (0)