Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions dist/copy-lyrics.user.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ==UserScript==
// @name Copy lyrics
// @namespace mkobayashime
// @version 1.4.5
// @version 1.4.6
// @description Copy lyrics automatically in supported sites
// @author mkobayashime
// @homepage https://github.com/mkobayashime/userscripts
Expand Down Expand Up @@ -45,10 +45,15 @@ var enableSelection = () => {
// src/userscripts/copy-lyrics/index.user.ts
void (() => {
const googleSearch = () => {
return Array.from(document.querySelectorAll("div[data-lyricid] > div > div > div > span"))
.map((element) => (element instanceof HTMLSpanElement ? element.innerText : null))
.filter((str) => str !== null)
.join("\n");
return Array.from(document.querySelectorAll("div[data-lyricid] > div > div > div"))
.map((e) =>
Array.from(e.querySelectorAll("& > span"))
.map((e2) => (e2 instanceof HTMLSpanElement ? e2.innerText : null))
.filter((str) => str !== null)
.join("\n"),
)
.filter((s) => s.length > 0)
.join("\n\n");
};
const utaNet = () => {
enableSelection();
Expand Down
15 changes: 10 additions & 5 deletions src/userscripts/copy-lyrics/index.user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { enableSelection } from "../utils/enableSelection";

export default defineUserScript({
name: "Copy lyrics",
version: "1.4.5",
version: "1.4.6",
description: "Copy lyrics automatically in supported sites",
match: [
"https://www.google.com/search*",
Expand All @@ -17,10 +17,15 @@ export default defineUserScript({
],
main: () => {
const googleSearch = () => {
return Array.from(document.querySelectorAll("div[data-lyricid] > div > div > div > span"))
.map((element) => (element instanceof HTMLSpanElement ? element.innerText : null))
.filter((str) => str !== null)
.join("\n");
return Array.from(document.querySelectorAll("div[data-lyricid] > div > div > div"))
.map((e) =>
Array.from(e.querySelectorAll("& > span"))
.map((e) => (e instanceof HTMLSpanElement ? e.innerText : null))
.filter((str) => str !== null)
.join("\n"),
)
.filter((s) => s.length > 0)
.join("\n\n");
};

const utaNet = () => {
Expand Down