embeds for sissys

Copy embeds, eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee

目前為 2025-11-01 提交的版本,檢視 最新版本

// ==UserScript==
// @name        embeds for sissys
// @namespace   Violentmonkey Scripts
// @match       https://x.com/*
// @grant       none
// @version     1.2
// @author      Lizzy, Lily
// @description Copy embeds, eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
// ==/UserScript==

function CascadeMenu() {
  let root = document.body.querySelector('[id="react-root"]');
  if (!root) return;
  let layers = root.firstChild.firstChild.querySelector('[id="layers"]');
  if (!layers) return;
  let group = layers.lastChild.firstChild.firstChild.firstChild.querySelector('[role="group"]');
  group?.firstChild?.firstChild?.click();
}

function clipboardz(url) {
  navigator.clipboard.writeText(url);
  CascadeMenu();
}

function AddToDropdown(elm) {
  if (elm.querySelector('[data-testid="girlcockxEmbed"]')) return;

  let IsValidDropdown = elm.querySelector('[data-testid="tweetEngagements"]');
  if (!IsValidDropdown) return;
  let ContentTarget = IsValidDropdown.getAttribute("href");
  if (!ContentTarget) return;

  const buttonz = (label, testid, urlPrefix) => {
    let Template = elm.firstChild.cloneNode(true);
    Template.getElementsByTagName('span')[0].textContent = label;
    Template.getElementsByTagName('svg')[0].firstChild.innerHTML = `<path d="M15.24 4.31l-4.55 15.93-1.93-.55 4.55-15.93 1.93.55zm-8.33 3.6L3.33 12l3.58 4.09-1.5 1.32L.67 12l4.74-5.41 1.5 1.32zm11.68-1.32L23.33 12l-4.74 5.41-1.5-1.32L20.67 12l-3.58-4.09 1.5-1.32z"></path>`;
    Template.setAttribute("data-testid", testid);
    Template.onclick = () => clipboardz(urlPrefix + ContentTarget.slice(0, -7));
    elm.firstChild.before(Template);
  };

  buttonz("Copy As girlcockx Embed", "girlcockxEmbed", "https://girlcockx.com");
  buttonz("Copy As fxtwitter Embed", "fxtwitterEmbed", "https://fxtwitter.com");
}

const observer = new MutationObserver(mutations => {
  mutations.forEach(mutation => {
    mutation.addedNodes.forEach(node => {
      if (node.firstChild?.lastChild?.matches('[data-testid="Dropdown"]')) {
        AddToDropdown(node.firstChild.lastChild);
      }
    });
  });
});

observer.observe(document.body, {
  childList: true,
  subtree: true,
  attributeFilter: ["style"]
});