niconico daily drawing link highlighter

ニコニコのデイリー福引リンクだけをハイライトする

// ==UserScript==
// @name         niconico daily drawing link highlighter
// @namespace    http://tampermonkey.net/
// @version      0.2
// @license MIT
// @description   ニコニコのデイリー福引リンクだけをハイライトする
// @author       Keisuke URAGO<bravo@resourcez.org>
// @match        https://blog.nicovideo.jp/niconews/category/ge_other/*
// @match       https://blog.nicovideo.jp/niconews/category/nicoad/*
// @icon         https://www.google.com/s2/favicons?domain=nicovideo.jp
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Your code here...
    function highlight(container,what, bgcolor, color) {
        bgcolor = bgcolor ? bgcolor : "#0CC";
        color = color ? color : "#000";
        const content = container.innerHTML,
            pattern = new RegExp('(>[^<.]*)(' + what + ')([^<.]*)','g'),
            replaceWith = `$1<span style="background:${bgcolor}; color: ${color}">$2</span>$3`,
            highlighted = content.replace(pattern,replaceWith);
        return (container.innerHTML = highlighted) !== content;
    }
    highlight(document.querySelector('.contents'), 'デイリー', '#F00', '#FFF');
    highlight(document.querySelector('.contents'), 'クイズ');
    highlight(document.querySelector('.contents'), 'キャンペーン', '#090', '#FFF');
    highlight(document.querySelector('.contents'), '福引', '#00F', '#FFF');
    // highlight(document.querySelector('.contents'), '還元');
    Array.from(document.querySelectorAll('.l-main a')).map(a=>a.setAttribute('target', '_blank'));
})();