网易歌单自动添加标签

实现自动添加歌单功能

目前為 2021-02-23 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name 网易歌单自动添加标签
  3. // @namespace https://music.163.com/
  4. // @version 2.0
  5. // @description 实现自动添加歌单功能
  6. // @author lacmac
  7. // @match https://www.geoguessr.com/battle-royale/*
  8. // @grant none
  9. // @connect restcountries.eu
  10. // ==/UserScript==
  11. (async function() {
  12. 'use strict';
  13. const apiURL = "https://restcountries.eu/rest/v2/alpha/";
  14. // Wait for ui to load
  15. while (!document.querySelector(".game-state-overview")) {
  16. await new Promise(r => setTimeout(r, 1000));
  17. }
  18. // Call manually once as flags may already be guessed. (Reconnecting, etc)
  19. showNames();
  20. // Show country code each time a new flag is guessed
  21. var observer = new MutationObserver(function(mutations) {
  22. for (let mutation of mutations) {
  23. if (mutation.type === "childList" && (mutation.target.className === "wrong-guesses__flags" || mutation.target.className === "game-state-overview")) {
  24. showNames();
  25. break;
  26. }
  27. }
  28. });
  29. // Start the observer on the guessed flags "list" element
  30. observer.observe(document.getElementsByClassName("game-state-overview")[0], { attributes: false, childList: true, characterData: false, subtree: true });
  31. function showNames() {
  32. // Retrieve all guessed flags
  33. let flags = document.getElementsByClassName("wrong-guesses__flag");
  34. for (let flag of flags) {
  35. let flag_div = flag.firstElementChild.firstElementChild.firstElementChild.firstElementChild;
  36. // Only add the country code once
  37. if (flag_div.parentNode.children.length === 1) {
  38. // Retrieve the 'alt' attribute from the flag img element
  39. let country_code = flag_div.firstElementChild.getAttribute("alt").toUpperCase();
  40. // Insert the html underneath the image and correct the country code
  41. flag_div.insertAdjacentHTML("afterend", '<span style="text-align: center;display: block;width: inherit;margin-top: 0.35rem;font-weight: bold;">Temp_Name</span>');
  42. flag_div.nextElementSibling.textContent = country_code;
  43. flag.style.marginBottom = "1rem";
  44. // Set the country name to show on hover
  45. fetch(apiURL + country_code)
  46. .then(res => res.json())
  47. .then(country => flag.setAttribute("title", country.name));
  48. flag.style.zIndex = 1;
  49. }
  50. }
  51. }
  52. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址