Skip to content

Instantly share code, notes, and snippets.

@mimonelu
Last active July 31, 2022 07:54
Show Gist options
  • Save mimonelu/15cdce24345c93c70f0b49552de365dd to your computer and use it in GitHub Desktop.
Save mimonelu/15cdce24345c93c70f0b49552de365dd to your computer and use it in GitHub Desktop.
LOSPEC用カラーピッカー
// LOSPEC用カラーピッカー
// SEE: https://lospec.com/palette-list
(() => {
const current = {
target: null,
style: null,
}
window.onmouseover = (event) => {
if (event.target.parentNode) {
current.target = event.target.parentNode
current.style = event.target.parentNode.style.outline
event.target.parentNode.style.outline = '2px solid #f00000'
}
}
window.onmouseout = (event) => {
if (current.target) {
current.target.style.outline = current.style
current.target = null
current.style = null
}
}
window.onclick = (event) => {
if (event.target.parentNode) {
const color = Array.prototype.slice.call(event.target.parentNode.querySelectorAll('.color')).map((node) => {
return node.style.background.match(/(\d+)/g).map((rgb) => {
return ('00' + parseInt(rgb, 10).toString(16)).slice(- 2)
}).join('')
}).join('\n')
prompt('', color)
}
}
})()
@mimonelu
Copy link
Author

mimonelu commented Jul 31, 2022

javascript: (()=>{let a={target:null,style:null};window.onmouseover=b=>{b.target.parentNode&&(a.target=b.target.parentNode,a.style=b.target.parentNode.style.outline,b.target.parentNode.style.outline="2px solid #f00000")},window.onmouseout=b=>{a.target&&(a.target.style.outline=a.style,a.target=null,a.style=null)},window.onclick=a=>{if(a.target.parentNode){let b=Array.prototype.slice.call(a.target.parentNode.querySelectorAll(".color")).map(a=>a.style.background.match(/(\d+)/g).map(a=>("00"+parseInt(a,10).toString(16)).slice(-2)).join("")).join("\n");prompt("",b)}}})(); void 0;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment