Last active
June 1, 2018 03:05
-
-
Save rinsuki/9c8112fd73a38ad3d717413f8e69a226 to your computer and use it in GitHub Desktop.
UserScriptで対抗2018
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 DisableCat | |
// @namespace https://rinsuki.net | |
// @version 0.1 | |
// @description 設定→Web→詳細設定→ストリームを経由したAPIリクエストをOFFにしたあとリロード | |
// @author rinsuki | |
// @match https://misskey.xyz/* | |
// @grant none | |
// @run-at document-start | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
// Your code here... | |
function disableNyaize(obj) { | |
if (obj == null) return obj | |
if (Array.isArray(obj)) { | |
return obj.map(disableNyaize) | |
} | |
if (typeof obj === "object") { | |
if (obj.text && obj.user && obj.user.isCat) obj.text = obj.text.replace(/にゃ/g, "な") | |
Object.keys(obj).forEach(key => obj[key] = disableNyaize(obj[key])) | |
return obj | |
} | |
return obj | |
} | |
const origJSONParse = JSON.parse | |
JSON.parse = (...args) => { | |
const ret = origJSONParse(...args) | |
return disableNyaize(ret) | |
} | |
const origResponsePrototypeJson = Response.prototype.json | |
Response.prototype.json = function(...args) { | |
return origResponsePrototypeJson.call(this).then(disableNyaize) | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment