// ==UserScript==
// @name esa.io cpl
// @namespace https://github.com/fushihara/esa-io-cpl
// @match https://*.esa.io/posts/*
// @description esa.ioのソースコードハイライト表示に機能追加
// @version 2.3.0
// @grant none
// @license MIT
// @source https://github.com/fushihara/esa-io-cpl
// @homepage https://greasyfork.org/ja/scripts/410892
// @noframes
// ==/UserScript==
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = "./src/index.ts");
/******/ })
/************************************************************************/
/******/ ({
/***/ "./src/esaCodeCopy.ts":
/*!****************************!*\
!*** ./src/esaCodeCopy.ts ***!
\****************************/
/*! exports provided: EsaCodeCopy */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EsaCodeCopy", function() { return EsaCodeCopy; });
const styleRuleInsertLog = new WeakMap();
const cssPrefix = `k777`;
class EsaCodeCopy {
constructor(element) {
this.element = element;
const fileNameElement = element.querySelector(".code-filename");
if (fileNameElement) {
const fileName = element.querySelector(".code-filename").innerText;
const insertElement = document.createElement("div");
insertElement.classList.add(cssPrefix);
insertElement.classList.add("code-block__copy-button");
for (let v of getButtons(fileName)) {
insertElement.appendChild(v.button);
}
element.querySelector(".highlight").appendChild(insertElement);
}
EsaCodeCopy.insertStyleRule();
}
static insertStyleRule() {
if (styleRuleInsertLog.has(document)) {
return;
}
styleRuleInsertLog.set(document, true);
const styleEl = document.createElement("style");
document.head.appendChild(styleEl);
styleEl.sheet.insertRule(`.markdown .code-block__copy-button.${cssPrefix}{ position: absolute;top: -25px;right: 0;border:0;}`);
styleEl.sheet.insertRule(`.markdown .code-block__copy-button.${cssPrefix} button{ font-family: monospace; font-size: 13px;line-height: 13px; }`);
// デフォルトのコードハイライトの高さを変える
styleEl.sheet.insertRule(`pre.highlight {line-height:13px;font-size:12px;font-family:SFMono-Regular,Consolas,Liberation Mono,Menlo,monospace; }`);
}
}
function copyText(str) {
navigator.clipboard.writeText(str);
}
function getButtons(filePath) {
const result = [];
const splitPath = [...filePath.split(/[\\\/]/)];
if (1 < splitPath.length) {
const element = document.createElement("button");
element.innerText = filePath;
element.addEventListener("click", () => {
copyText(filePath);
});
result.push({
button: element,
type: "all",
});
}
for (let path of splitPath) {
const element = document.createElement("button");
element.innerText = path;
element.addEventListener("click", () => {
copyText(path);
});
result.push({
button: element,
type: "path",
});
}
return result;
}
/***/ }),
/***/ "./src/index.ts":
/*!**********************!*\
!*** ./src/index.ts ***!
\**********************/
/*! no exports provided */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var _esaCodeCopy__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./esaCodeCopy */ "./src/esaCodeCopy.ts");
main();
function main() {
const elements = document.querySelectorAll(".markdown > div.code-block");
for (let e of elements) {
new _esaCodeCopy__WEBPACK_IMPORTED_MODULE_0__["EsaCodeCopy"](e);
}
}
/***/ })
/******/ });
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly8vd2VicGFjay9ib290c3RyYXAiLCJ3ZWJwYWNrOi8vLy4vc3JjL2VzYUNvZGVDb3B5LnRzIiwid2VicGFjazovLy8uL3NyYy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7O1FBQUE7UUFDQTs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