Skip to content

Instantly share code, notes, and snippets.

@protospork
Last active December 16, 2015 22:59
Show Gist options
  • Save protospork/5510644 to your computer and use it in GitHub Desktop.
Save protospork/5510644 to your computer and use it in GitHub Desktop.
Hides certain forum threads from appearing on the WK dashboard.
// ==UserScript==
// @id wk-dashboard-forum-hide
// @name WaniKani: hide irrelevant forums
// @version 1.1
// @namespace
// @author protospork
// @description
// @include https://www.wanikani.com/dashboard
// @require https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
// @run-at document-idle
// ==/UserScript==
//if this is true, the script always takes effect.
//if false, it only takes effect when you have reviews to do
var hide_always = true;
//these are css selectors: https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors
var to_hide = [
"a[href*='campfire']", //yes, the entire subforum
"a[href*='kanji-and-japanese/726']", //shiritori
];
//nothing below here needs editing
var box = $(".forum-topics-list").find("tbody");
var kill = false;
var count = 0;
var reviews_pending = $(".reviews").find("span").text();
console.log(reviews_pending+" reviews available.");
$(box).children().each(function(key, val){
if (reviews_pending.match(/^\s*0\s*$/) &&! hide_always){
return false;
}
console.log("Iterating: "+$(val).prop("tagName")+" "+count);
if ($(val).has("td.description").length){
//post item
for (var i = 0; i < to_hide.length; i++){
if ($(val).find(to_hide[i]).length){
console.log("Removing "+count+": "+$(val).find("a").first().text());
$(val).remove();
kill = true;
}
}
} else if ($(val).find("hr").length) {
//divider
if (kill){
$(val).remove();
kill = false;
}
}
count++;
});
@protospork
Copy link
Author

It should be removing the divider before the removed post, not after. Whoops.

@protospork
Copy link
Author

Updated to detect available reviews.

@protospork
Copy link
Author

Updated for https-only on WK

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment