Created
October 17, 2019 09:26
-
-
Save yuta0801/6e701fb0aaa2d645ac2ecafceaf8ae42 to your computer and use it in GitHub Desktop.
UserScript port of https://github.com/bromne/wired-normalizer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name Wired Normalizer | |
| // @namespace https://github.com/bromne/wired-normalizer | |
| // @version 1.3.0 | |
| // @description WIRED.jp の記事に含まれる「ヴ」を、適当なバ行の文字に変換します。 | |
| // @author @bromne, @yuta0801 | |
| // @match *://wired.jp/* | |
| // @grant none | |
| // @require //ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js | |
| // ==/UserScript== | |
| $(function() { | |
| var rules = [ | |
| [/ヴェイ/g, "ベー"], | |
| [/ヴュ/g, "ビュ"], | |
| [/ヴァ/g, "バ"], | |
| [/ヴィ/g, "ビ"], | |
| [/ヴェ/g, "ベ"], | |
| [/ヴォ/g, "ボ"], | |
| [/ヴ/g, "ブ"], | |
| ]; | |
| var replaceCharacters = function() { | |
| $('body :not(script,iframe)').contents().filter(function() { | |
| return this.nodeType === 3 && this.nodeValue.match(/^[\n \t ]*$/) === null; | |
| }).replaceWith(function() { | |
| return rules.reduce(function(text, rule) { | |
| return text.replace(rule[0], rule[1]); | |
| }, this.nodeValue); | |
| }); | |
| }; | |
| replaceCharacters(); | |
| $("#main-article-detail-container,#loaded-more-articles").each(function(i, element) { | |
| var observer = new MutationObserver((dom, instance) => replaceCharacters()); | |
| observer.observe(element, { childList: true }); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment