JSFiddle - React, Tailwind, and code Playground

by philll_t

HTML

<div class="gh-header-show">
  <h1>
    <span class="markdown-title">Create Generic/ Waringn @!!#@$^%$^&^$&*</span>
    <span class="f1-light color-fg-muted">#321321</span>
  </h1>
</div>

<a href='javascript:!function(){const e=document.querySelector(".gh-header-show h1"),t=e.querySelector("span.markdown-title"),o=`git checkout -b "${`${e.querySelector("span.f1-light.color-fg-muted").innerText} ${t.innerText}`.replace(/\W+/gm," ").trim().toLowerCase().replace(/\s/g,"-")}"`,c=document.createElement("textarea");c.value=o,document.body.appendChild(c),c.select(),document.execCommand("copy"),document.body.removeChild(c)}();'>Get Branch Create Command</a>

<button onclick="test()">
copy to clipboard
</button>
git checkout -b "321321-create-generic-waringn"

JavaScript

const test = (function () {

	const header = document.querySelector(".gh-header-show h1");
  const title = header.querySelector("span.markdown-title");
  const issue_number = header.querySelector("span.f1-light.color-fg-muted");
  const pr_name = `${issue_number.innerText} ${title.innerText}`.replace(/\W+/gm, " ").trim().toLowerCase().replace(/\s/g, "-")

  const git_command = `git checkout -b "${pr_name}"`;

   const elem = document.createElement('textarea');
   elem.value = git_command;
   document.body.appendChild(elem);
   elem.select();
   document.execCommand('copy');
   document.body.removeChild(elem);
})()