您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Part-of-Speech filter for Wanikani Open Framework
- // ==UserScript==
- // @name Wanikani Part-of-Speech Filter
- // @namespace rfindley
- // @description Part-of-Speech filter for Wanikani Open Framework
- // @version 1.0.1
- // @include https://www.wanikani.com/*
- // @copyright 2018+, Robin Findley
- // @license MIT; http://opensource.org/licenses/MIT
- // @run-at document-end
- // @grant none
- // ==/UserScript==
- window.pos_filter = {};
- (function(gobj) {
- /* global $, wkof */
- // Only load if Open Framework is installed.
- if (!window.wkof) return
- wkof.ready('ItemData')
- .then(GetPartsOfSpeech)
- .then(AddFilter);
- var parts_of_speech = {};
- // Extract the list of parts of speech from all vocabulary.
- function GetPartsOfSpeech()
- {
- return wkof.ItemData.get_items().then(function(items) {
- var pos_list = {};
- for (var item_idx in items) {
- var item = items[item_idx];
- if (item.object !== 'vocabulary') continue;
- var item_pos = item.data.parts_of_speech;
- for (var pos_idx in item_pos) {
- pos_list[item_pos[pos_idx]] = 1;
- }
- }
- pos_list = Object.keys(pos_list).sort();
- for (pos_idx in pos_list) {
- var pos = pos_list[pos_idx];
- parts_of_speech[pos] = pos;
- }
- return parts_of_speech;
- });
- }
- // Add the filter to the Open Framework registry.
- function AddFilter() {
- wkof.ItemData.registry.sources.wk_items.filters.part_of_speech = {
- type: 'multi',
- label: 'Part of speech',
- content: parts_of_speech,
- default: [],
- filter_func: function(filter_value, item){
- window.filter_value = filter_value;
- if (item.object !== 'vocabulary') return false;
- var item_pos = item.data.parts_of_speech;
- for (var pos_idx in item_pos) {
- var pos = item_pos[pos_idx];
- if (filter_value[pos]) return true;
- }
- return false;
- },
- hover_tip: 'Filter by part of speech (noun, i-adjective, ...)',
- };
- wkof.set_state('pos_filter', 'ready');
- }
- })(window.pos_filter);
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址