PopupMenuとPopClipのポップアップが重ならないようにする
Macの便利アプリPopClip
↓ これを
↓ こうします
script.jsif (/Macintosh/.test(navigator.userAgent) && !/Porter/.test(navigator.userAgent)) {
setTimeout(() => {
const observer = new MutationObserver(records => {
for (const record of records) {
for (const node of record.addedNodes) {
if (node.getAttribute('class') !== 'selections') {
continue;
}
const popup = node.getElementsByClassName('popup-menu')[0];
if (!popup) return;
popup.style.top = (() => {
const selectionList = document.getElementsByClassName('selection');
let lowestSelection = selectionList[0];
const length = selectionList.length;
if (length !== 1) {
for (let i = 1; i < length; i++) {
if (parseInt(selectionList[i-1].style.top) < parseInt(selectionList[i].style.top)) {
lowestSelection = selectionList[i];
}
}
}
return (parseInt(lowestSelection.style.top) + parseInt(lowestSelection.style.height) + popup.clientHeight + 25) + 'px';
})();
const triangleStyle = popup.getElementsByClassName('triangle')[0].style;
triangleStyle.borderTop = 'none';
triangleStyle.borderBottom = '6px solid #111';
triangleStyle.top = '-6px';
break;
}
}
});
observer.observe(document.getElementById('editor'), { childList: true });
}, 2000);
}