GTMと聞いて別のサービスを思い浮かべるのは私だけでないはず。
そこで正しいサービスに戻してみようと思います。
ここの記事を参考にさせていただきました。
LGTMを戻す
gtm/gtm.js
window.onload = function() {
var img = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAARgAAAC0CAMAAAB4+cOfAAAApVBMVEX///9FhPA5abtYkPE9gPA1Z7pGcr9liMgwZLkoYLiOr/W+y+WIoNE1fO/R4PtBgvAweu+nwPfy9v73+v7s8v1glPLg6fzl7f1+pvQ+bb5Jhe3M2/q7z/l1ofPF1vra5fyYt/a90fmUtfavx/ijv/dqmvJ9pfTS2+5dkvJRi/GOsfWUq9mqvN+Fq/Szyfgmdu98mM9ZfsNSesLD0OihtNvX3/Czw+K2RX0AAAALAElEQVR4nO2dbUPiOBDHWxtWcDekPJQi8qQ8rKB4rnvn9/9oh+hqUpJ2JpmUlrt5bWPzI00yk/9MgsCbDabL7W6SRLWwZDIfp/5YfFq6WDHOGWMiFLWwUDDGk7FnLO3VnklYPxN8dOsTS8LrSOXd4knXE5b+motT987FWOhnqhnX8huSTQgPZHqruNbD5WAi7FFzSUXdh8vB2ISYy5SfuktExmnXpk69Z13ZRpRclucyXvbGn/7nojURkXGZnxOX/ZChWrKvzotLyIi8puGZcQnZHQmXyVlsX2QTJFuZ1dlxIZl9e8n5caHYyXSjc+QShq5c+puz2e6q5solJOIihGAlmQC9shuXASPhIljMVsOrkmwd8bj4vZ24tEm2LyJOxn23Hwhr6SIq8nhdmr+h4CL4cEDVX4y1V7EvMLcUXNimTdZX7PuHeeupfbtjivAL39F1FG29vB27dauL/JEI5ELjkljb0EzGtsklBRd2yvFyMLM3Y9ngHQUXkZB20sZ6xv2pXXs7kvWI+Tr0Q1hqGjJWra1J9i+8Q9xJK3swDBmbtojCLyPycy0b6zZHRGB6ROEXtqTvpY39aGjJoNvpUYUZyOLNjvazda0jg22mSxVmEPc+emljrYaODLKR/ogqLEUUbiawy+aFhgyujQEslgEC41vWBbaH5oWGDKqJGU345WD8x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EKhWe8NIBvFgalVSUlaz4C5ltgBToyKk6uYOVYTfBkx9ytZG1gPGDkxdCh0rR6mmuKfB7MDUozS2In6CyYW+zBJMLYqpK1XPjGcrBrMGU/3y+0rpBEQxyXezB1P5CxvUQDX2aQcwFb/iY2lbyffdXMDU51IY9D0WjmDqco1QKPDXlbqB+S9cPGUHphZXlcFLskrmCqayl9vFX5fb4XyBD3MGU9XrEAef1yEurC7QfnUGQ3uBpsVs4Mce3cFgdCJFhkom9GpvV666gqG8pNdmnvRilw0CMITXOmPCsl5N8yVZgCG8CBxYbte3/SYCQ3d1PChnxr89a6YYKzBkYQjUJUjerK8bMJZggjXJVg9/1aUP+6EbMLZgaHQisAIDnu2ndsBYg5Gr6zqQOf3C1Gto1moXMJmKzJYGrCvr0X5pPyQXMDQ6EauLuwnt0sDFBUwwthHKH5HBB9zorPti4uIEBlgPrcBY8puso0j73TBycQNDoxMRo+d/qLqKsZ+XLf28SwAGU/A5h0zUePm7ZDbp40vLPFzcwQQDigCNiL61Wq2X5x8l2fOv/b/LGS0UYII+hU5kT6Zx0WiWZgVQSMAEfYowxIFMpcwdTNClCENUjgwBGBqdSNXIUICh0YlUjcwLBRiSAE21yDQuScCQ6EQqRab5QAMmuDozMq1XIjAkOpEKkWkh5Wo5RhGgqQwZmkXpwxYEYYiqkGk9EoIhCUNUhMw1JReaM/9KkGl9pwUTdDfuG5oKkGkSbWJk27lPwScn07jA6/iK7cZdDnFiMo2mn0P1HvoqzWqRaX7zJjZId65oTkem0br08R19orkL3diciEyjdU3mCpisfTdi/CClFG+n1GjbkynZmq3Wi3csB+vObjvz+XaSRDa2uizZHl6VyeVfPfgkISZjQFYAAAAASUVORK5CYII=';
var hideStyle = document.createElement('style');
hideStyle.type = 'text/css';
hideStyle.innerHTML = `.hideButtonTitle {
display: none !important;
}`;
document.body.appendChild(hideStyle);
// tooltipを消す
var hideTootipStyle = document.createElement('style');
hideTootipStyle.type = 'text/css';
hideTootipStyle.innerHTML = `.MuiTooltip-popper {
display: none;
}`;
document.body.appendChild(hideTootipStyle);
// mobile
var mobileLike = document.querySelector('div.it-ActionsMobile_like');
var mobileLikeStyle = document.createElement('style');
mobileLikeStyle.type = 'text/css';
mobileLikeStyle.innerHTML = `.mobileLike {
background-color: white !important;
border: 2px solid rgb(93, 112, 124) !important;
}`;
document.body.appendChild(mobileLikeStyle);
mobileLike.classList.add('mobileLike');
mobileLike.addEventListener('click', function() {
setTimeout(function() {
mobileLike.classList.add('mobileLike');
}, 0);
});
mobileLike.addEventListener('mouseover', function() {
setTimeout(function() {
mobileLikeButton.classList.add('hideButtonTitle');
mobileLikeButton.title = 'Google Tag なんとか';
mobileLikeButton.classList.remove('hideButtonTitle');
}, 0);
});
var mobileLikeButton = mobileLike.querySelector('button');
var buttonStyle = document.createElement('style');
buttonStyle.type = 'text/css';
buttonStyle.innerHTML = `.mobileLikeButton {
display: flex;
justify-content: center;
align-items: center;
}`;
document.body.appendChild(buttonStyle);
mobileLikeButton.title = 'Google Tag Manager';
mobileLikeButton.classList.add('mobileLikeButton');
var span = mobileLikeButton.querySelector('span:first-child');
span.parentNode.removeChild(span);
mobileLikeButton.insertAdjacentHTML('afterbegin', '<img src="' + img + '" style="width: 45px; margin-right: 10px;" />');
var mobileCount = mobileLikeButton.querySelector('span:last-child');
var countStyle = document.createElement('style');
countStyle.type = 'text/css';
countStyle.innerHTML = `.likeCount {
color: rgb(93, 112, 124);
}`;
document.body.appendChild(countStyle);
mobileCount.classList.add('likeCount');
// footer
var footerLike = document.querySelector('div.it-Footer_like');
footerLike.title = 'Google Tag Manager';
footerLike.addEventListener('mouseover', function() {
setTimeout(function() {
footerLike.classList.add('hideButtonTitle');
footerLike.title = 'Google Tag なんとか';
footerLike.classList.remove('hideButtonTitle');
}, 0);
});
var footerButton = footerLike.querySelector('button');
var footerButtonStyle = document.createElement('style');
footerButtonStyle.type = 'text/css';
footerButtonStyle.innerHTML = `.footerLikeButton {
background-color: transparent !important;
border: none !important;
}`;
document.body.appendChild(footerButtonStyle);
footerButton.classList.add('footerLikeButton');
footerButton.innerHTML = '<img width=45 src="' + img + '" />';
var footerCount = footerLike.querySelector('a');
footerCount.classList.add('likeCount');
};
manifest.jsonの設定を書きます。
gtm/manifest.json
{
"name": "GTM",
"version": "1.0.0",
"manifest_version": 2,
"description": "GTM Chrome Extension",
"content_scripts": [{
"matches": ["https://qiita.com/**/items/*"],
"js": [
"gtm.js"
]
}]
}
早速戻してみましょう・・・おっと、サービスを間違えたようです
これは酷い