Hi folks. I’m using the auto-ignore script for the Chinese HSK courses (which sadly require its use). I believe it was created by @Spurdosparde. Currently it takes a list of words, and auto-ignores words which are on that list. I want to modify it so that it does the opposite: ignore any words not on the list.
Here is the script:
// ==UserScript==
// @name Memrise auto ignore for HSK
// @namespace http://localhost
// @description Spurdosparde’s script adapted to all HSK
// @include https://www.memrise.com/course/*
// @version 1
// @grant none
// ==/UserScript==
var HSK1vocab = [‘爱’,‘八’,‘爸爸’,‘杯子’,‘北京’,‘本’,‘不客气’,‘不’,‘菜’,‘茶’,‘吃’,‘出租车’,‘打電話’,‘大’,‘的’,‘点’,‘电脑’,‘电视’,‘电影’,‘东西’,‘都’,‘读’,‘对不起’,‘多’,‘多少’,‘儿子’,‘二’,‘饭店’,‘飞机’,‘高兴’,‘个’,‘工作’,‘狗’,‘汉语’,‘好’,‘喝’,‘和’,‘很’,‘后面’,‘回’,‘会’,‘火车站’,‘几’,‘岁’,‘家’,‘叫’,‘今天’,‘九’,‘开’,‘看’,‘看见’,‘块’,‘来’,‘老师’,‘了’,‘冷’,‘里’,‘零’,‘六’,‘妈妈’,‘吗’,‘买’,‘猫’,‘没’,‘没关系’,‘米饭’,‘名字’,‘明天’,‘哪儿’,‘那’,‘呢’,‘能’,‘你’,‘你们’,‘年’,‘女儿’,‘朋友’,‘苹果’,‘七’,‘钱’,‘前面’,‘请’,‘去’,‘热’,‘人’,‘认识’,‘日’,‘三’,‘商店’,‘上’,‘上午’,‘少’,‘什么’,‘十’,‘时候’,‘是’,‘书’,‘谁’,‘水’,‘水果’,‘睡覺’,‘说话’,‘四’,‘他’,‘她’,‘他们’,‘她们’,‘太’,‘天气’,‘听’,‘同学’,‘我’,‘我们’,‘五’,‘喜欢’,‘下’,‘下午’,‘下雨’,‘先生’,‘现在’,‘想’,‘小’,‘小姐’,‘些’,‘写’,‘谢谢’,‘星期’,‘学生’,‘学习’,‘学校’,‘一’,‘衣服’,‘医生’,‘医院’,‘椅子’,‘有’,‘月’,‘在’,‘再见’,‘怎么’,‘怎么样’,‘这’,‘中国’,‘中午’,‘住’,‘桌子’,‘字’,‘昨天’,‘做’,‘坐’];var vocab = HSK1vocab; //this specifices which characters are looked for. If you want to do HSK4, you want to auto-ignore all characters from HSK3 and hence choose the HSK3vocab variable here. If you want to do HSK5, take the HSK4vocab variable.
//Button to call ignore-function
var input = document.createElement(‘input’);
input.type = ‘button’;
input.value = ‘GreaseMonkey: ignore words’;
input.onclick = pageHandling; //calls main function
input.setAttribute(‘style’, ‘font-size:18px;position:absolute;top:120px;right:40px;’);
document.body.appendChild(input);
//presses the ignore button, ticks off words that coincide with the list, saves changes.
function pageHandling() {
var ignoreButton = document.getElementsByClassName(‘ignore-show button mini’);
ignoreButton[0].click(); //clicks the ignore-Button of the memrise webpage, opening the menu that allows to select characters to ignore.
ignoreWords(); //ignores the respective words, see function below
saveChanges();
}
//looks through the words and ticks off those that already exist in the vocab variablefunction ignoreWords()
{
var characters = document.getElementsByClassName(‘thing text-text’);
for (var i = 0; i < characters.length; i++)
{
var col_b = characters[i].getElementsByClassName(‘col_b col text’);
for (var j = 0; j < vocab.length; j++)
{
if (col_b[0].textContent != vocab[j])
{
var checkBox = characters[i].getElementsByTagName(‘input’); //the checkbox of this character
checkBox[0].checked = true; //checks the checkbox
}
}
}
}
//saves changes after the boxes have been tickedfunction saveChanges()
{
var saveButton = document.getElementsByClassName(‘ignore-save ignore-ui btn pull-right btn-primary btn-large btn-block hide’);
saveButton[0].click();
}
I had though that by modifying the following line as indicated it would do the tick, but apparently it’s not that simple.
if (col_b[0].textContent != vocab[j])
Is anyone able to help?
Edit: It was a bit long with all the words listed in the script, so I’ve cut most of the lists out. You still get the idea. I can’t seem to get it to preserve the indentation for some reason. Here it is in pastebin: https://pastebin.com/qHU9zQ0T