UserScript:background-image-2
痛モードのテスト用ユーティリティ(その2 ワイドモード)
code:script.js
scrapbox.PageMenu.addItem({
title: 'background-image-2',
onClick: (e) => {
var style = document.getElementById('__itab__')
if (style)
{
style.remove()
e.currentTarget.innerText = 'background-image-2'
return
}
const image = prompt("url")
console.log(image)
const result = regex.test(image);
if(result != true) {
e.currentTarget.innerText = 'background-image-2'
return
} else {
e.currentTarget.innerText ='✅background-image-2'
}
const css =
'body {'
+ ' background-image: url("' + image + '");'
+ ' background-repeat: repeat-y;'
+ ' background-attachment: scroll;'
+ ' background-position: center top ;'
+ ' background-size: 100% auto;' // 横幅を100%にして算出
+ '}'
+ '.page {'
+ ' opacity:0.8;'
+ '}'
+ ' .page:hover {'
+ ' opacity:1;'
+ '}'
//console.log(css)
style = document.createElement('style')
style.setAttribute('id', '__itab__')
style.appendChild(document.createTextNode(css))
document.head.appendChild(style)
}
})
UserScript.icon