Print Code

Print.

2018/06/28のページです。最新版はこちら

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

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

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name         Print Code
// @namespace    http://tampermonkey.net/
// @version      0.1.0
// @description  Print.
// @author       Feng Ya
// @match        https://github.com/*
// @grant        none
// ==/UserScript==

;(function () {
  'use strict'
  // Your code here...
  if (!document.querySelector('div.file')) return

  console.log('print code')

  const btnPrint = document.createElement('a')
  btnPrint.classList.add('btn')
  btnPrint.classList.add('btn-sm')
  btnPrint.classList.add('BtnGroup-item')
  console.log(btnPrint.classList)
  btnPrint.innerHTML = 'Print'
  btnPrint.addEventListener('click', printCode)

  document
    .querySelector('div.file-actions > div.BtnGroup')
    .appendChild(btnPrint)

  function printCode () {
    const file = document.querySelector('div.file')
    const header = document.querySelector('div.file-header')

    header.style.display = 'none'

    document.querySelectorAll('body > div').forEach(div => {
      div.style.display = 'none'
    })

    document.body.appendChild(file)
  }
})()