sjehuda / Simple sign in button

// ==UserScript== 
// @name        Simple sign in button
// @author      Schimon Jehudah, Adv.
// @copyright   2022, 2024, Schimon Jehudah (http://schimon.i2p)
// @license     AGPL-3.0-only; https://www.gnu.org/licenses/agpl-3.0.en.html
// @namespace   org.openuserjs.sjehuda.simplebutton
// @description Remove the intrusive header bar in favour of a button.
// @match       https://github.com/* 
// @version     1.0.1
// @grant       none
// @homepageURL  https://openuserjs.org/scripts/sjehuda/Simple_sign_in_button
// @supportURL   https://openuserjs.org/scripts/sjehuda/Simple_sign_in_button/issues
// @updateURL    https://openuserjs.org/meta/sjehuda/Simple_sign_in_button.meta.js
// @downloadURL  https://openuserjs.org/install/sjehuda/Simple_sign_in_button.user.js
// ==/UserScript==

var signInLink = document.evaluate('//a[contains(@href, "/login?")]/@href', document, null, XPathResult.STRING_TYPE).stringValue;

if (signInLink) {
  document.querySelector('header').remove();
  let elementsignIn = document.createElement('a');
  //elementsignIn.textContent = '🔌';
  elementsignIn.textContent = 'Connect';
  elementsignIn.title = 'You are encouraged to migrate to cgit or Codeberg or Forgejo or Gitea or GitLab';
  elementsignIn.setAttribute ('aria-label', 'Connect to account.');
  elementsignIn.style.background = '#000';
  elementsignIn.style.color = '#fff';
  elementsignIn.href = signInLink;
  elementsignIn.className = 'tooltipped tooltipped-sw btn-sm btn';
  let elementLi = document.createElement('li');
  elementLi.append(elementsignIn);
  let elementButtons = document.querySelector('#repository-details-container > ul');
  if (elementButtons) {
    elementButtons.append(elementLi);
  } else {
    let elementHeaderSlim = document.createElement('div');
    elementHeaderSlim.style.background = '#333';
    elementHeaderSlim.style.fontWeight = 'bold';
    elementHeaderSlim.style.padding = '1em';
    elementHeaderSlim.style.textAlign = 'center';
    elementsignIn.textContent = 'Connect to CrapHub';
    elementsignIn.href = signInLink;
    elementsignIn.style.color = '#fff';
    elementHeaderSlim.append(elementsignIn);
    document.body.prepend(elementHeaderSlim);
  }
}