gyazo-url-2-thumbnail
code:gyazo-url-2-thumbnail.tampermonkey.user.js
// ==UserScript==
// @name MindManagerでエクスポートしたHTMLでGyazoの画像URL文字列をサムネイルに変換する
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://sho-ichiro.com/mindmap/*/*.html
// @icon https://www.google.com/s2/favicons?domain=sho-ichiro.com
// @grant none
// ==/UserScript==
(function() {
'use strict';
setTimeout(()=>Gyazoの画像URL文字列をサムネイルに変換(), 3000);
function Gyazoの画像URL文字列をサムネイルに変換(){
document.querySelectorAll('.joint-cells-layer.joint-viewport g text tspan').forEach((elm)=>{
if(elm.textContent.includes('https://gyazo')){
let a = document.createElement('a');
a.setAttribute('href', elm.textContent);
a.setAttribute('target', '_blank');
let image = document.createElement('image');
image.setAttribute('xlink:href', elm.textContent);
image.setAttribute('width', '300');
image.setAttribute('x', '0');
image.setAttribute('y', '0');
// <image width="300" xlink:href="https://gyazo.com/b85b160d9dace6372cac6c3e2532a52b.png" x="30" y="20" width="328"></image>
let imageOuterHTML = <image width="300" xlink:href="${elm.textContent}" x="30" y="0"></image>;
// a.appendElement(image);
a.appendChild(image);
// a.innerHTML = image.outerHTML;
// a.innerHTML = imageOuterHTML;
// elm.parentElement.parentElement.innerHTML = a.outerHTML;
elm.parentElement.parentElement.innerHTML = a.outerHTML;
// elm.parentElement.parentElement.querySelector('a').innerHTML = imageOuterHTML;
// elm.style.background = 'yellow';
}
});
}
})();