Initial project files

This commit is contained in:
ItzzExcel
2025-02-09 04:11:20 -06:00
parent 74a17e1bb3
commit 10aa31c967
12 changed files with 1487 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
{
"dependencies": {
"canvas-confetti": "^1.6.0"
}
}
+6
View File
@@ -0,0 +1,6 @@
{
"name": "Copy Lyrics",
"description": "A working neptune plugin that allows the user to copy the lyrics of a song selecting it.",
"author": "itzzexcel@github",
"main": "./src/index.js"
}
+16
View File
@@ -0,0 +1,16 @@
lockfileVersion: '6.1'
settings:
autoInstallPeers: true
excludeLinksFromLockfile: false
dependencies:
canvas-confetti:
specifier: ^1.6.0
version: 1.6.0
packages:
/canvas-confetti@1.6.0:
resolution: {integrity: sha512-ej+w/m8Jzpv9Z7W7uJZer14Ke8P2ogsjg4ZMGIuq4iqUOqY2Jq8BNW42iGmNfRwREaaEfFIczLuZZiEVSYNHAA==}
dev: false
+70
View File
@@ -0,0 +1,70 @@
import toast, { Toaster } from 'react-hot-toast';
const unlockSelection = `
[class^="lyricsText"]>div>span {
user-select: text;
cursor: text;
}`;
function ApplyCSS(style) {
const styleElement = document.createElement('style');
styleElement.type = 'text/css';
if (styleElement.styleSheet)
styleElement.styleSheet.cssText = style;
else
styleElement.appendChild(document.createTextNode(style));
document.head.appendChild(styleElement);
}
function SetClipboar(text) {
const textarea = document.createElement('textarea');
textarea.value = text;
textarea.style.position = 'fixed'; // Avoid scrolling to the bottom
document.body.appendChild(textarea);
textarea.select();
try {
const success = document.execCommand('copy');
if (success) {
console.log('Text copied to clipboard:', text);
toast.success('Copied to clipboard!');
} else {
throw new Error('Failed to copy text.');
}
} catch (err) {
console.error('Failed to copy text:', err);
toast.error('Failed to copy to clipboard!');
} finally {
document.body.removeChild(textarea);
}
}
ApplyCSS(unlockSelection);
let isSelecting = false;
document.addEventListener('mousedown', function() {
isSelecting = true;
});
document.addEventListener('mouseup', function() {
if (isSelecting) {
const selection = window.getSelection();
if (selection.toString().length > 0) {
let text = selection.toString();
SetClipboar(text);
toast.success("Copied to clipboard!");
if (window.getSelection) {
const selection = window.getSelection();
selection.removeAllRanges();
}
} else {
}
isSelecting = false;
}
});
export function onUnload() {
console.log("Goodbye world!");
}