Last active
August 24, 2019 10:21
-
-
Save YoshiTheChinchilla/270e36c8a32ecf3fb274db312d16efa1 to your computer and use it in GitHub Desktop.
Ignoring Chinese repositories on GitHub Trending https://gist.github.com/YoshiTheChinchilla/270e36c8a32ecf3fb274db312d16efa1/raw/ignore-chinese-repos.user.js
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 Chinese Repository Ignorer | |
// @namespace https://gist.github.com/YoshiTheChinchilla/ | |
// @version 1.0.0 | |
// @description Ignoring Chinese repositories on GitHub Trending | |
// @author Takashi Yoshimura | |
// @encoding utf-8 | |
// @homepage https://gist.github.com/YoshiTheChinchilla/ | |
// @match https://github.com/trending* | |
// @exclude https://github.com/trending/developers* | |
// @license MIT | |
// @run-at document-end | |
// @grant none | |
// @iconURL https://raw.githubusercontent.com/linssen/country-flag-icons/master/images/png/chn.png | |
// @icon64URL https://raw.githubusercontent.com/linssen/country-flag-icons/master/images/png/chn.png | |
// @updateURL https://gist.github.com/YoshiTheChinchilla/270e36c8a32ecf3fb274db312d16efa1/raw/ignore-chinese-repos.user.js | |
// @downloadURL https://gist.github.com/YoshiTheChinchilla/270e36c8a32ecf3fb274db312d16efa1/raw/ignore-chinese-repos.user.js | |
// @supportURL https://gist.github.com/YoshiTheChinchilla/270e36c8a32ecf3fb274db312d16efa1#new_comment_field | |
// ==/UserScript== | |
// Version History: | |
// | |
// 1.0.0 (2019-08-15): Create this script and publish it on https://gist.github.com/YoshiTheChinchilla/270e36c8a32ecf3fb274db312d16efa1 | |
// | |
// https://github.com/alsotang/is-chinese/blob/master/ischinese.js | |
const chineseCharRegex = /[\u4e00-\u9fff]|[\u3400-\u4dbf]|[\u{20000}-\u{2a6df}]|[\u{2a700}-\u{2b73f}]|[\u{2b740}-\u{2b81f}]|[\u{2b820}-\u{2ceaf}]|[\uf900-\ufaff]|[\u3300-\u33ff]|[\ufe30-\ufe4f]|[\uf900-\ufaff]|[\u{2f800}-\u{2fa1f}]/u | |
const isChineseText = (text) => chineseCharRegex.test(text) | |
const log = (e) => console.info(`Removed ${e.querySelector('a').href}`) || e | |
const makeInvisible = (e) => (e.style.display = 'none') && e | |
const main = () => { | |
console.group(`ignore-chinese-repos logs on ${window.location.href}`); | |
[...document.querySelectorAll('.Box-row')].filter((e) => isChineseText(e.querySelector('p').textContent.trim())).map(makeInvisible).map(log) | |
console.groupEnd() | |
} | |
main() | |
/** | |
The MIT License (MIT) | |
Copyright (c) 2019 Takashi Yoshimura | |
Permission is hereby granted, free of charge, to any person obtaining a copy of | |
this software and associated documentation files (the "Software"), to deal in | |
the Software without restriction, including without limitation the rights to | |
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | |
the Software, and to permit persons to whom the Software is furnished to do so, | |
subject to the following conditions: | |
The above copyright notice and this permission notice shall be included in all | |
copies or substantial portions of the Software. | |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | |
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | |
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | |
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | |
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
**/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment