whee / filter_porn

// ==UserScript==
// @name         filter_porn
// @namespace    http://tover.me/
// @version      0.8
// @description  fiter porn content, and turn to https://bing.ioliu.cn/ranking
// @author       whee
// @match        http://*/*
// @grant        none
// @include      *
// @exclude      https://openuserjs.org/*
// @copyright 2020, whee (https://openuserjs.org/users/whee)
// @license GPL-3.0-or-later
// ==/UserScript==

(function () {
  'use strict';
  var week_day = new Date().getDay();
  var random_num = Math.floor(Math.random() * 100);

  var key_words = ['porn', '色情', '情色', '成人','肉文','高肉','辣文','高辣','小说','h小说','高h','高H'];
  var title = document.title;
  var metas = document.getElementsByTagName('meta');
  var target_meta;
  for (var meta of metas) {
    var name = meta.name;
    if (name === 'description') {
      target_meta = meta;
    }
  }
  if (target_meta) {
    var description = target_meta.content;
    for (var key of key_words) {
      if (description.indexOf(key) != -1) {
        window.location.href = "https://lib-pku.github.io/";
      }
    }
  }
  else {
    for (var key of key_words) {
      if (title.indexOf(key) != -1) {
        window.location.href = "https://lib-pku.github.io/";
      }
    }
  }

})();