<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF xmlns="http://purl.org/rss/1.0/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel rdf:about="https://let.hatelabo.jp/nanikamado/rss">
    <link>https://let.hatelabo.jp/nanikamado/rss</link>
    <description></description>
    <title>Bookmarklets from nanikamado</title>
    <items>
      <rdf:Seq>
        <rdf:li rdf:resource="https://let.hatelabo.jp/nanikamado/let/hJmc796wtdp2"/>
        <rdf:li rdf:resource="https://let.hatelabo.jp/nanikamado/let/hLHU5aii3YU5"/>
      </rdf:Seq>
    </items>
  </channel>
  <item rdf:about="https://let.hatelabo.jp/nanikamado/let/hJmc796wtdp2">
    <link>https://let.hatelabo.jp/nanikamado/let/hJmc796wtdp2</link>
    <dc:date>2018-06-19T12:24:26Z</dc:date>
    <description>サイトの背景色を黒にし、文字色を明るくします。詳しい説明はソースコード内の先頭のコメントを見てください。</description>
    <dc:creator>nanikamado</dc:creator>
    <title>[Let] darkmode</title>
    <content:encoded>&lt;a href="javascript:%28%28%29%3D%3E%7B%27use%20strict%27%3Blet%20bgcolor%3D%27rgb%2822%2C22%2C22%29%27%3Blet%20time%3D%7Ball%3ADate.now%28%29%7D%3Bconst%20computedStyleMap%3Dnew%20WeakMap%3Bconst%20formatColorCode%3Dbgcolor%3D%3E%7Bif%28bgcolor.slice%280%2C1%29%3D%3D%3D%27%23%27%29return%27rgb%28%27%2B%28bgcolor.length%3D%3D%3D4%3Fbgcolor.slice%281%2C4%29.split%28%27%27%29.map%28%28st%3D%3Est%2Bst%29%29%3Abgcolor.slice%281%2C7%29.match%28%2F..%2Fg%29%29.map%28%28_bgc%3D%3EparseInt%28_bgc%2C16%29%29%29.join%28%22%2C%22%29%2B%27%29%27%3Bif%28bgcolor.slice%280%2C3%29%21%3D%3D%27rgb%27%29%7Blet%20_cDiv%3Ddocument.createElement%28%27div%27%29%3B_cDiv.style.setProperty%28%27color%27%2Cbgcolor%2C%27important%27%29%3Bif%28%21_cDiv.style.color%29%7Bconsole.log%28%27color%20code%20is%20invalid%27%29%3Breturn%7Ddocument.body.appendChild%28_cDiv%29%3Blet%20color%3Dwindow.getComputedStyle%28_cDiv%29.color%3B_cDiv.remove%28%29%3Breturn%20color%7Dconsole.error%28%27bgcolor%3D%27%2Bbgcolor%29%7D%2CsetColor%3D%28node%2CignoreDCStyle%29%3D%3E%7Blet%20dCStyle%3Blet%20nodeStyleText%3Dnode.style.cssText%3Bif%28%21ignoreDCStyle%26%26%28dCStyle%3Dnode.getAttribute%28%27darkComputedStyle%27%29%29%29%7Bif%28%21~nodeStyleText.indexOf%28dCStyle%29%29node.style.cssText%3DdCStyle%3Breturn%7Dif%28node.getAttribute%28%27darkBeforeStyle%27%29%3D%3D%3Dnull%29node.setAttribute%28%27darkBeforeStyle%27%2CnodeStyleText%29%3Blet%20CS_C%2CCS_BC%2CCS_BI%2CCS%3Bif%28computedStyleMap.has%28node%29%29%7Blet%20sCS%3DcomputedStyleMap.get%28node%29%3BCS_C%3DsCS.C%3BCS_BC%3DsCS.BC%3BCS_BI%3DsCS.BI%3BCS%3DsCS.CS%7Delse%7BCS%3Dwindow.getComputedStyle%28node%29%3BCS_C%3DCS.color%3BCS_BC%3DCS.backgroundColor%3BCS_BI%3DCS.backgroundImage%7Dif%28%21CS_C%29return%3Bconst%5Br%2Cg%2Cb%5D%3DCS_C.match%28%2F%5Cd%2B%2Fg%29.slice%280%2C3%29.map%28Number%29%3Bconst%20s%3D255-Math.max%28r%2Cg%2Cb%29%3Bnode.style.setProperty%28%27color%27%2C%60rgb%28%24%7Br%2Bs%7D%2C%24%7Bg%2Bs%7D%2C%24%7Bb%2Bs%7D%29%60%2Cnode.tagName%3D%3D%3D%27A%27%3F%27%27%3A%27important%27%29%3Bif%28CS_BC%21%3D%3D%27rgba%280%2C%200%2C%200%2C%200%29%27%29%7Bif%28CS_BC.slice%283%2C4%29%21%3D%3D%27a%27%29%7Bnode.style.setProperty%28%27background-color%27%2Cbgcolor%2C%27important%27%29%7Delse%7Bif%28bgcolor.slice%280%2C3%29%21%3D%3D%27rgb%27%29%7Bbgcolor%3DformatColorCode%28bgcolor%29%7Dnode.style.setProperty%28%27background-color%27%2Cbgcolor.replace%28%27rgb%27%2C%27rgba%27%29.replace%28%27%29%27%2C%27%2C%27%29%2BCS_BC.replace%28%2F%5B%5E%2C%5D%2A%2C%5B%5E%2C%5D%2B%2C%5B%5E%2C%5D%2B%2C%5B%5E%2C%5Cd%5D%2A%28%5Cd%3F.%3F%5Cd%2B%29%2F%2C%27%241%27%29%2C%27important%27%29%7D%7Dif%28CS_BI.indexOf%28%27gradient%27%29%21%3D%3D-1%29node.style.backgroundImage%3DCS_BI.replace%28%2F%5B%5E%2C%5D%2Agradient%5C%28%28%3F%3A%5B%5E%5C%28%5C%29%5D%2A%5C%28%28%3F%3A%5B%5E%5C%28%5C%29%5D%2A%5C%28%5B%5E%5C%28%5C%29%5D%2A%5C%29%29%2A%5B%5E%5C%28%5C%29%5D%2A%5B%5E%5C%28%5C%29%5D%2A%5C%29%29%2A%5B%5E%5C%28%5C%29%5D%2A%5C%29%2C%3F%2Fgi%2C%27%27%29%7C%7C%27none%27%3Bnode.setAttribute%28%27darkComputedStyle%27%2Cnode.style.cssText.split%28%27%3B%27%29.filter%28%28cssplo%3D%3E%7Bswitch%28cssplo.split%28%27%3A%27%29%5B0%5D.replace%28%27%20%27%2C%27%27%29%29%7Bcase%27background-color%27%3Acase%27color%27%3Areturn%20true%3Bdefault%3Areturn%20false%7D%7D%29%29.join%28%27%3B%27%29%29%7D%2CallElm%3D%28%29%3D%3E%7Blet%20all%3D%5Bdocument.body%2Cdocument.body.parentNode%2C...document.body.querySelectorAll%28%27%2A%27%29%5D%3Bdocument.body.querySelectorAll%28%27iframe%27%29.forEach%28%28iframe%3D%3E%7Bif%28new%20URL%28iframe.src%2Clocation.href%29.origin%3D%3D%3Dlocation.origin%7C%7C%21iframe.src%7C%7Ciframe.src%3D%3D%3D%27about%3Ablank%27%29%7Ball.push%28...%5B...iframe.contentDocument.body.querySelectorAll%28%27%2A%27%29%2Ciframe.contentDocument.body%5D%29%7D%7D%29%29%3Breturn%20all%7D%2CsetColorAll%3D%28%29%3D%3E%7BallElm%28%29.forEach%28setColor%29%3Bdocument.body.style.setProperty%28%27background-color%27%2Cbgcolor%2C%27important%27%29%3Bdocument.body.querySelectorAll%28%27A%27%29.forEach%28%28node%3D%3E%7Bif%28getComputedStyle%28node%29.color%21%3D%3Dnode.style.color%29node.style.setProperty%28%27color%27%2Cnode.style.color%2C%27important%27%29%7D%29%29%7D%2Cmain%3D%28%29%3D%3E%7Blet%20darkVisitedStyle%3Ddocument.body.querySelector%28%27.darkVisitedStyle%27%29%3Bif%28darkVisitedStyle%29%7BallElm%28%29.forEach%28%28node%3D%3E%7Bif%28%21node.style%29return%3Bconst%20style%3Dnode.getAttribute%28%27darkBeforeStyle%27%29%3Bif%28style%3D%3D%3Dnull%29return%3Bnode.style.cssText%3Dstyle%7D%29%29%3BdarkVisitedStyle.remove%28%29%3Bconsole.log%28%271%27%29%7Delse%7BallElm%28%29.forEach%28%28node%3D%3E%7Bconst%20CS%3Dwindow.getComputedStyle%28node%29%3BcomputedStyleMap.set%28node%2C%7BC%3ACS.color%2CBC%3ACS.backgroundColor%2CBI%3ACS.backgroundImage%2CCS%3ACS%7D%29%7D%29%29%3Blet%20elmsSetedStyle%3D%5B%5D%3Bconst%20observer%3Dnew%20MutationObserver%28%28maa%3D%3E%7Bif%28%21document.body.querySelector%28%27.darkVisitedStyle%27%29%29%7Bobserver.disconnect%28%29%3Breturn%7Dmaa.forEach%28%28ma%3D%3E%7Bif%28ma.type%3D%3D%3D%27childList%27%29%7Bma.addedNodes.forEach%28%28addedNode%3D%3E%7Bif%28addedNode.nodeType%21%3D%3D1%29return%3B%5BaddedNode%2C...addedNode.querySelectorAll%28%27%2A%27%29%5D.forEach%28setColor%29%7D%29%29%7Delse%7Bconst%20darkComputedStyle%3Dma.target.getAttribute%28%27darkComputedStyle%27%29%7C%7C%27%27%3Bif%28~ma.target.style.cssText.indexOf%28darkComputedStyle%29%29%7Bconsole.log%28%27return%20cssText%3D%3D%3DDCS%27%29%3Breturn%7Dlet%20DCStyleOb%3D%7B%7D%3Bfor%28const%20styleProp%20of%20darkComputedStyle.split%28%27%3B%27%29%29%7Bconst%20s%3DstyleProp.split%28%27%3A%27%29%3BDCStyleOb%5Bs%5B0%5D.replace%28%27%20%27%2C%27%27%29%5D%3Ds%5B1%5D.replace%28%27%21important%27%2C%27%27%29.replace%28%2F%20%2Fg%2C%27%27%29%7Dif%28%28%21DCStyleOb%5B%27color%27%5D%7C%7CDCStyleOb%5B%27color%27%5D%3D%3D%3Dma.target.style.color.replace%28%2F%20%2Fg%2C%27%27%29%29%26%26%28%21DCStyleOb%5B%27background-color%27%5D%7C%7CDCStyleOb%5B%27background-color%27%5D%3D%3D%3Dma.target.style.backgroundColor.replace%28%2F%20%2Fg%2C%27%27%29%29%29%7Bconsole.log%28%27return%20DCSColor%3D%3D%3Dcolor%26%26DCSBackgroundColor%3D%3D%3Dbackgroundcolor%27%29%3Breturn%7Dlet%20ind%3Bif%28%28ind%3DelmsSetedStyle.map%28%28e%3D%3Ee.elm%29%29.indexOf%28ma.target%29%29%3E%3D0%29%7Bif%28%2B%2BelmsSetedStyle%5Bind%5D.num%3E%3D10%29%7Bconsole.log%28%7B0%3A%27avoided%20infinite%20loop%20%3D%3E%27%2Cnum%3AelmsSetedStyle%5Bind%5D.num%2Ccolor%3Ama.target.style.color.replace%28%2F%20%2Fg%2C%27%27%29%2Cbgcolor%3Ama.target.style.backgroundColor.replace%28%2F%20%2Fg%2C%27%27%29%7D%29%3Breturn%7D%7Delse%20elmsSetedStyle.push%28%7Belm%3Ama.target%2Cnum%3A0%7D%29%3BsetColor%28ma.target%2Ctrue%29%7D%7D%29%29%3Bconsole.log%28%27Mutation%27%29%7D%29%29%3Blet%20resizeTimer%3Bconst%20resizeListener%3D%28%29%3D%3E%7Bconsole.log%28%27resizing%27%29%3Bif%28resizeTimer%29clearTimeout%28resizeTimer%29%3BresizeTimer%3DsetTimeout%28%28%28%29%3D%3E%7Bif%28document.body.querySelector%28%27.darkVisitedStyle%27%29%29setColorAll%28%29%3Belse%20window.removeEventListener%28%27resize%27%2CresizeListener%29%7D%29%2C500%29%7D%3Bwindow.addEventListener%28%27resize%27%2CresizeListener%29%3Bconst%20darkStyle%3Ddocument.createElement%28%27style%27%29%3BdarkStyle.textContent%3D%60a%3Avisited%7Bcolor%3A%23b553ff%21important%7D%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%2A%7Btext-shadow%3Anone%21important%7D%3Aafter%2C%3Abefore%7Bbackground-color%3Atransparent%21important%7D%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3A%3A-webkit-scrollbar%7Boverflow%3Ahidden%3Bwidth%3A.8rem%3Bbackground%3A%23000%7D%5Cn%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3A%3A-webkit-scrollbar-thumb%7Boverflow%3Ahidden%3Bborder-radius%3A.4rem%3Bbackground%3A%23ddd%7D%60%3BdarkStyle.className%3D%27darkVisitedStyle%27%3Bdocument.body.appendChild%28darkStyle%29%3BsetColorAll%28%29%3Bobserver.observe%28document.body%2C%7BchildList%3Atrue%2Csubtree%3Atrue%2CattributeFilter%3A%5B%27style%27%5D%2Cattributes%3Atrue%7D%29%3Bconsole.log%28%270%27%29%7D%7D%3Bif%28document.readyState%3D%3D%3D%27loading%27%29document.addEventListener%28%27DOMContentLoaded%27%2Cmain%29%3Belse%20main%28%29%3Btime.all%3DDate.now%28%29-time.all%3Bconsole.log%28time%29%7D%29%28%29%3B"&gt;darkmode&lt;/a&gt;&lt;pre&gt;/*
 * @title darkmode
 * @description サイトの背景色を黒にし、文字色を明るくします。詳しい説明はソースコード内の先頭のコメントを見てください。
 * @include http://*
 * @include https://*
 * @contributor noromanba   http://let.hatelabo.jp/noromanba/let/hJmc5cn7v_h5
 * @license     MIT license https://opensource.org/licenses/MIT
 * @javascript_url
 */


// 背景の色を黒にします。ただし、背景が透明の場合は変更しません。
// 文字色の彩度を最大にします。
// 訪問したことのあるリンクの色を紫にします。
// 稀に色を変えられないこともあります。仕様です。
// 画像の色は変わりません。
// 一度実行した状態でもう一度実行すると、もとに戻ります。
// 'use strict'の次の行の、bgcolorに入れる値を変更することで、背景色を変えることができます。
// http://let.hatelabo.jp/nanikamado/let/hLHU5aii3YU5  の改良版です。


(() =&amp;gt; {
    'use strict';
    let bgcolor = 'rgb(22,22,22)';
    let time = {
        all: Date.now()
    };
    const computedStyleMap = new WeakMap();
    const formatColorCode = bgcolor =&amp;gt; {
            if (bgcolor.slice(0, 1) === '#')
                return 'rgb(' +
                    (bgcolor.length === 4 ? bgcolor.slice(1, 4).split('').map(st =&amp;gt; st + st) : bgcolor.slice(1, 7).match(/../g))
                    .map(_bgc =&amp;gt; parseInt(_bgc, 16)).join(&amp;quot;,&amp;quot;) + ')';
            if (bgcolor.slice(0, 3) !== 'rgb') {
                let _cDiv = document.createElement('div');
                _cDiv.style.setProperty('color', bgcolor, 'important');
                if (!_cDiv.style.color) { console.log('color code is invalid'); return };
                document.body.appendChild(_cDiv);
                let color = window.getComputedStyle(_cDiv).color;
                _cDiv.remove();
                return color;
            }
            console.error('bgcolor=' + bgcolor);
        },
        setColor = (node, ignoreDCStyle) =&amp;gt; {
            let dCStyle;
            let nodeStyleText = node.style.cssText;
            if (!ignoreDCStyle &amp;amp;&amp;amp; (dCStyle = node.getAttribute('darkComputedStyle'))) {
                if (!~nodeStyleText.indexOf(dCStyle)) node.style.cssText = dCStyle;
                return;
            };
            if (node.getAttribute('darkBeforeStyle') === null) node.setAttribute('darkBeforeStyle', nodeStyleText);
            let CS_C, CS_BC, CS_BI, CS;
            if (computedStyleMap.has(node)) {
                let sCS = computedStyleMap.get(node);
                CS_C = sCS.C;
                CS_BC = sCS.BC;
                CS_BI = sCS.BI;
                CS = sCS.CS;
            } else {
                CS = window.getComputedStyle(node);
                CS_C = CS.color;
                CS_BC = CS.backgroundColor;
                CS_BI = CS.backgroundImage;
            };
            if (!CS_C) return;
            const [r, g, b] = CS_C.match(/\d+/g).slice(0, 3).map(Number);
            const s = 255 - Math.max(r, g, b);
            //color
            node.style.setProperty('color', `rgb(${r+s},${g+s},${b+s})`, node.tagName === 'A' ? '' : 'important');
            //backgroundColor
            if (CS_BC !== 'rgba(0, 0, 0, 0)') {
                if (CS_BC.slice(3, 4) !== 'a') {
                    node.style.setProperty('background-color', bgcolor, 'important');
                } else {
                    if (bgcolor.slice(0, 3) !== 'rgb') {
                        bgcolor = formatColorCode(bgcolor);
                    }
                    node.style.setProperty('background-color', bgcolor.replace('rgb', 'rgba').replace(')', ',') +
                        CS_BC.replace(/[^,]*,[^,]+,[^,]+,[^,\d]*(\d?.?\d+)/, '$1'), 'important');
                }
            }
            //backgroundImage gradient
            if (CS_BI.indexOf('gradient') !== -1)
                node.style.backgroundImage = CS_BI
                .replace(/[^,]*gradient\((?:[^\(\)]*\((?:[^\(\)]*\([^\(\)]*\))*[^\(\)]*[^\(\)]*\))*[^\(\)]*\),?/gi, '') || 'none';

            node.setAttribute('darkComputedStyle', node.style.cssText.split(';').filter(cssplo =&amp;gt; {
                switch (cssplo.split(':')[0].replace(' ', '')) {
                    case 'background-color':
                    case 'color':
                        return true;
                    default:
                        return false;
                }
            }).join(';'));
        },
        allElm = () =&amp;gt; {
            let all = [document.body, document.body.parentNode, ...document.body.querySelectorAll('*')];
            document.body.querySelectorAll('iframe').forEach(iframe =&amp;gt; {
                if ((new URL(iframe.src, location.href)).origin === location.origin || !iframe.src || iframe.src === 'about:blank') {
                    all.push(...[
                        ...iframe.contentDocument.body.querySelectorAll('*'),
                        iframe.contentDocument.body
                    ]);
                };
            });
            return all;
        },
        setColorAll = () =&amp;gt; {
            allElm().forEach(setColor);
            document.body.style.setProperty('background-color', bgcolor, 'important');
            document.body.querySelectorAll('A').forEach(node =&amp;gt; {
                if (getComputedStyle(node).color !== node.style.color) node.style.setProperty('color', node.style.color, 'important');
            });
        },
        main = () =&amp;gt; {
            let darkVisitedStyle = document.body.querySelector('.darkVisitedStyle');
            if (darkVisitedStyle) { //even times
                allElm().forEach(node =&amp;gt; {
                    if (!node.style) return;
                    const style = node.getAttribute('darkBeforeStyle');
                    if (style === null) return;
                    node.style.cssText = style;
                });
                darkVisitedStyle.remove();
                console.log('1');
            } else { //odd times
                allElm().forEach(node =&amp;gt; {
                    const CS = window.getComputedStyle(node);
                    computedStyleMap.set(node, {
                        C: CS.color,
                        BC: CS.backgroundColor,
                        BI: CS.backgroundImage,
                        CS: CS
                    });
                });
                let elmsSetedStyle = [];
                const observer = new MutationObserver(maa =&amp;gt; {
                    if (!document.body.querySelector('.darkVisitedStyle')) {
                        observer.disconnect();
                        return;
                    };
                    maa.forEach(ma =&amp;gt; {
                        if (ma.type === 'childList') {
                            ma.addedNodes.forEach(addedNode =&amp;gt; {
                                if (addedNode.nodeType !== 1) return;
                                [addedNode, ...addedNode.querySelectorAll('*')].forEach(setColor);
                            });
                        } else {
                            const darkComputedStyle = ma.target.getAttribute('darkComputedStyle') || '';

                            if (~ma.target.style.cssText.indexOf(darkComputedStyle)) {
                                console.log('return cssText===DCS');
                                return
                            };
                            let DCStyleOb = {};
                            for (const styleProp of darkComputedStyle.split(';')) {
                                const s = styleProp.split(':');
                                DCStyleOb[s[0].replace(' ', '')] = s[1].replace('!important', '').replace(/ /g, '');
                            };
                            if ((!DCStyleOb['color'] || DCStyleOb['color'] === ma.target.style.color.replace(/ /g, '')) &amp;amp;&amp;amp;
                                (!DCStyleOb['background-color'] || DCStyleOb['background-color'] === ma.target.style.backgroundColor.replace(/ /g, ''))) {
                                console.log('return DCSColor===color&amp;amp;&amp;amp;DCSBackgroundColor===backgroundcolor');
                                return
                            };

                            let ind;
                            if ((ind = elmsSetedStyle.map(e =&amp;gt; e.elm).indexOf(ma.target)) &amp;gt;= 0) {
                                if (++elmsSetedStyle[ind].num &amp;gt;= 10) {
                                    console.log({
                                        0: 'avoided infinite loop =&amp;gt;',
                                        num: elmsSetedStyle[ind].num,
                                        color: ma.target.style.color.replace(/ /g, ''),
                                        bgcolor: ma.target.style.backgroundColor.replace(/ /g, '')
                                    });
                                    return;
                                }
                            } else elmsSetedStyle.push({
                                elm: ma.target,
                                num: 0
                            });
                            setColor(ma.target, true);
                        }
                    });
                    console.log('Mutation');
                });

                let resizeTimer;
                const resizeListener = () =&amp;gt; {
                    console.log('resizing');
                    if (resizeTimer) clearTimeout(resizeTimer);
                    resizeTimer = setTimeout(() =&amp;gt; {
                        if (document.body.querySelector('.darkVisitedStyle')) setColorAll();
                        else window.removeEventListener('resize', resizeListener);
                    }, 500);
                };
                window.addEventListener('resize', resizeListener);

                const darkStyle = document.createElement('style');
                darkStyle.textContent = `a:visited{color:#b553ff!important}
                *{text-shadow:none!important}:after,:before{background-color:transparent!important}
                ::-webkit-scrollbar{overflow:hidden;width:.8rem;background:#000}
                ::-webkit-scrollbar-thumb{overflow:hidden;border-radius:.4rem;background:#ddd}`;
                darkStyle.className = 'darkVisitedStyle';
                document.body.appendChild(darkStyle);

                setColorAll();
                observer.observe(document.body, {
                    childList: true,
                    subtree: true,
                    attributeFilter: ['style'],
                    attributes: true,
                });
                console.log('0');
            };
        };
    if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', main);
    else main();
    time.all = Date.now() - time.all;
    console.log(time);
})();&lt;/pre&gt;</content:encoded>
  </item>
  <item rdf:about="https://let.hatelabo.jp/nanikamado/let/hLHU5aii3YU5">
    <link>https://let.hatelabo.jp/nanikamado/let/hLHU5aii3YU5</link>
    <dc:date>2018-05-05T01:32:53Z</dc:date>
    <description>サイトの背景を黒に、文字色を、元々の色の彩度を最大にしたものにします。 2種類モードがあり、実行するたび切り替わります:1.一番下の背景色が透明に、その他の要素の背景色が透明になります。 2.ほぼすべての要素の背景色が黒になります。 1より見た目は悪いです。</description>
    <dc:creator>nanikamado</dc:creator>
    <title>[Let] 黒背景</title>
    <content:encoded>&lt;a href="javascript:%28%28%29%3D%3E%7Blet%20my_style%2Call%3Ddocument.querySelectorAll%28%27%2A%27%29%2Cmode%3D%28my_style%3Ddocument.querySelector%28%27.dark_visited_style%27%29%29%3FNumber%28my_style.getAttribute%28%27mode_stat%27%29%29%3A0%2Cset_color%3Delm%3D%3E%7Belm.forEach%28%28v%3D%3E%7Blet%20c%3Dwindow.getComputedStyle%28v%29.getPropertyValue%28%27color%27%29%2Cc_ob%3D%7Br%3ANumber%28c.replace%28%2Frgba%3F%5C%28%28%5Cd%7B1%2C3%7D%29%2C%20%5Cd%7B1%2C3%7D%2C%20%5Cd%7B1%2C3%7D.%2A%2F%2C%27%241%27%29%29%2Cg%3ANumber%28c.replace%28%2Frgba%3F%5C%28%5Cd%7B1%2C3%7D%2C%20%28%5Cd%7B1%2C3%7D%29%2C%20%5Cd%7B1%2C3%7D.%2A%2F%2C%27%241%27%29%29%2Cb%3ANumber%28c.replace%28%2Frgba%3F%5C%28%5Cd%7B1%2C3%7D%2C%20%5Cd%7B1%2C3%7D%2C%20%28%5Cd%7B1%2C3%7D%29.%2A%2F%2C%27%241%27%29%29%7D%3Blet%20s%3D255-Math.max%28c_ob.r%2Cc_ob.g%2Cc_ob.b%29%3Bv.style.color%3D%60rgb%28%24%7Bc_ob.r%2Bs%7D%2C%20%24%7Bc_ob.g%2Bs%7D%2C%20%24%7Bc_ob.b%2Bs%7D%29%60%7D%29%29%7D%2Cset_color_all%3D%28style%3Dmy_style_text%29%3D%3E%7Bset_color%28all%29%3Bdocument.querySelectorAll%28%27iframe%27%29.forEach%28%28v%3D%3E%7Bif%28v.src%26%26new%20URL%28v.src%2Clocation%29.origin%3D%3Dlocation.origin%7C%7Cv.src%3D%3D%27about%3Ablank%27%29%7Bset_color%28v.contentDocument.querySelectorAll%28%27%2A%27%29%29%3Blet%20my_style%3Dv.contentDocument.createElement%28%22style%22%29%3Bmy_style.innerText%3Dstyle%3Bv.contentDocument.body.appendChild%28my_style%29%7D%7D%29%29%7D%3Bconst%20my_style_text%3D%27a%3Avisited%7Bcolor%3A%23b553ff%21important%3B%7D%3Anot%28html%29%7Bbackground-color%3Atransparent%21important%7Dhtml%7Bbackground-color%3A%23000%21important%7D%3A%3A-webkit-scrollbar%7Boverflow%3Ahidden%3Bwidth%3A.8rem%3Bbackground%3A%23000%3B%7D%3A%3A-webkit-scrollbar-thumb%7Boverflow%3Ahidden%3Bborder-radius%3A.4rem%3Bbackground%3A%23ddd%3B%7D%27%3Bswitch%28mode%29%7Bcase%200%3Aset_color_all%28%29%3Bmy_style%3Ddocument.createElement%28%22style%22%29%3Bmy_style.className%3D%27dark_visited_style%27%3Bmy_style.innerText%3Dmy_style_text%3Bdocument.body.appendChild%28my_style%29%3Bmy_style.setAttribute%28%27all_elm_length%27%2Call.length%29%3Bmy_style.setAttribute%28%27mode_stat%27%2C1%29%3Bconsole.log%28%270%27%29%3Bbreak%3Bcase%201%3Amy_style.innerText%3D%27%2A%7Bbackground-color%3A%23000%21important%7D%27%3Bif%28my_style.getAttribute%28%27all_elm_length%27%29%21%3Dall.length%29%7Bset_color_all%28%27%2A%7Bbackground-color%3A%23000%21important%7D%27%29%3Bmy_style.setAttribute%28%27all_elm_length%27%2Call.length%29%7Dmy_style.setAttribute%28%27mode_stat%27%2C2%29%3Bconsole.log%28%271%27%29%3Bbreak%3Bcase%202%3Amy_style.innerText%3Dmy_style_text%3Bif%28my_style.getAttribute%28%27all_elm_length%27%29%21%3Dall.length%29%7Bset_color_all%28%29%3Bmy_style.setAttribute%28%27all_elm_length%27%2Call.length%29%7Dmy_style.setAttribute%28%27mode_stat%27%2C1%29%3Bconsole.log%28%272%27%29%3Bbreak%3Bdefault%3Aalert%28%27error%20%20mode_stat%3D%27%2Bmode%29%3Bbreak%7D%7D%29%28%29%3B"&gt;黒背景&lt;/a&gt;&lt;pre&gt;/*
 * @title 黒背景
 * @description サイトの背景を黒に、文字色を、元々の色の彩度を最大にしたものにします。 2種類モードがあり、実行するたび切り替わります:1.一番下の背景色が透明に、その他の要素の背景色が透明になります。 2.ほぼすべての要素の背景色が黒になります。 1より見た目は悪いです。
 * @javascript_url
 * @license  The MIT license
 */
(()=&amp;gt;{
    let my_style,
        all = document.querySelectorAll('*'),
        mode = (my_style = document.querySelector('.dark_visited_style')) ? Number(my_style.getAttribute('mode_stat')) : 0,
        set_color = elm =&amp;gt; {
            elm.forEach((v) =&amp;gt; {
                let c = window.getComputedStyle(v).getPropertyValue('color'),
                    c_ob = {
                        r: Number(c.replace(/rgba?\((\d{1,3}), \d{1,3}, \d{1,3}.*/, '$1')),
                        g: Number(c.replace(/rgba?\(\d{1,3}, (\d{1,3}), \d{1,3}.*/, '$1')),
                        b: Number(c.replace(/rgba?\(\d{1,3}, \d{1,3}, (\d{1,3}).*/, '$1')),
                    };
                let s = 255 - Math.max(c_ob.r, c_ob.g, c_ob.b);
                v.style.color = `rgb(${c_ob.r+s}, ${c_ob.g+s}, ${c_ob.b+s})`;
            });
        },
        set_color_all = (style = my_style_text) =&amp;gt; {
            set_color(all);
            document.querySelectorAll('iframe').forEach((v) =&amp;gt; {
                if (v.src &amp;amp;&amp;amp; (new URL(v.src, location)).origin == location.origin || v.src == 'about:blank') {
                    set_color(v.contentDocument.querySelectorAll('*'));
                    let my_style = v.contentDocument.createElement(&amp;quot;style&amp;quot;);
                    my_style.innerText = style;
                    v.contentDocument.body.appendChild(my_style);
                }
            })
        };
    const my_style_text = 'a:visited{color:#b553ff!important;}:not(html){background-color:transparent!important}html{background-color:#000!important}::-webkit-scrollbar{overflow:hidden;width:.8rem;background:#000;}::-webkit-scrollbar-thumb{overflow:hidden;border-radius:.4rem;background:#ddd;}';
    switch (mode) {
        case 0:
            set_color_all();
            my_style = document.createElement(&amp;quot;style&amp;quot;);
            my_style.className = 'dark_visited_style';
            my_style.innerText = my_style_text;
            document.body.appendChild(my_style);
            my_style.setAttribute('all_elm_length', all.length);
            my_style.setAttribute('mode_stat', 1);
            console.log('0');
            break;
        case 1:
            my_style.innerText = '*{background-color:#000!important}';
            if (my_style.getAttribute('all_elm_length') != all.length) {
                set_color_all('*{background-color:#000!important}');
                my_style.setAttribute('all_elm_length', all.length);
            }
            my_style.setAttribute('mode_stat', 2);
            console.log('1');
            break;
        case 2:
            my_style.innerText = my_style_text;
            if (my_style.getAttribute('all_elm_length') != all.length) {
                set_color_all();
                my_style.setAttribute('all_elm_length', all.length);
            }
            my_style.setAttribute('mode_stat', 1);
            console.log('2');
            break;
        default:
            alert('error  mode_stat=' + mode);
            break;
    }
})()&lt;/pre&gt;</content:encoded>
  </item>
</rdf:RDF>
