Copy Simply Johnny's

I just wanna copy something

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name Copy Simply Johnny's
// @namespace bambooom
// @version 0.3
// @description I just wanna copy something
// @author bambooom
// @homepageURL https://zhuzi.dev
// @supportURL https://zhuzi.dev
// @license MIT
// @match https://*.johnnys-net.jp/*
// @match https://*.johnnys-web.com/*
// @match https://*.johnny-associates.co.jp/*
// @match https://johnnys-shop.jp/*
// @match https://*.johnnys-shop.jp/*
// @match https://j-island.net/*
// @match https://*.j-island.net/*
// @run-at document-end
// @grant unsafeWindow
// ==/UserScript==

(function() {
  let css = `
    body{
      user-select: auto!important;
    }
    h1, h2, h3, h4, h5, p, span, img {
      user-select: auto!important;
    }
    *:not(input) {
      user-select: auto!important;
    }

    .visually-hidden {
      border: 0;
      clip: rect(0,0,0,0);
      position: absolute;
      width: 1px;
      height: 1px;
      margin: -1px;
      overflow: hidden;
      padding: 0;
     }
  `;
  let styleNode = document.createElement("style");
  styleNode.appendChild(document.createTextNode(css));
  (document.querySelector("head") || document.documentElement).appendChild(styleNode);

  let donot = [...document.querySelectorAll('script')].filter(n => /donot\.js$/.test(n.src));
  if (donot.length) {
    donot[0].remove();
  }
  unsafeWindow.KEY_ENABLE = 1;
  unsafeWindow.________J && unsafeWindow.________J.doNot({
      selectContent: null,
      captureImages: null,
     useContextMenu: null,
            useKeys: null,
  });

  if (/johnnys-web\.com/.test(unsafeWindow.location.hostname)) {
    unsafeWindow.navigator.userAgent = 'Mozilla/5.0 (iPad; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1';
    unsafeWindow.navigator.appVersion = '5.0 (iPad; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1';
    //location.href = 'https://www.johnnys-web.com/s/jwb/?ima=4442';
    var post = document.querySelector('.entry__content .entry__body');
    if (post) {
      post = post.textContent.trim();
      var row = document.querySelector('.entry__posted_on');
      var color = getComputedStyle(document.querySelector('.blog .section-article .entry__date')).color;
      var btn = document.createElement('button');
      btn.style.color = color;
      btn.style.border = 'solid 2px ' + color;
      btn.style.borderRadius = '3px';
      btn.style.padding = '4px 6px';
      btn.textContent = 'Copy Full Text';
      row.appendChild(btn);
      var input = document.createElement('textarea');
      input.classList.add('visually-hidden');
      input.id = 'copy-full-text';
      document.body.appendChild(input);
      btn.onclick = function () {
        input.value = post;
        input.select();
        let success = document.execCommand('copy');
        window.getSelection().removeAllRanges();
        if (success) {
          console.log('copied');
        }
      };
    }
  }
})();