"Real Numbers" Script working in one Google Chrome Profile, but not another?


#1

Hi everyone,

I’ve used these 2 google chrome profiles (1 is personal, and the other is for work) for many years, having wanikani as a bookmark on both chrome profiles. I’ve also used tampermonkey and user mempo’s “WaniKani Real Numbers” without difficulty with my Mac Air.

I just got a Dell XPS 15, making the switch back to PC. Naturally, I’m just syncing my google profiles again, getting 'em how I like 'em. I generally only use Wani-Kani scripts, “Real Numbers” and “WaniKani Override.”

The latter works perfectly fine on both chrome profiles, but “Real Numbers” is only working on my work one… despite me using the exact same Mempo’s “WaniKani Real Numbers” version 4. Even opening my Tampermonkey shows the exact same 2 scripts are being used, but what could be causing the discrepancy? I’m honestly baffled, and would appreciate any advice.

Thanks in advance.


#2

Mind showing us some console output?


#3

Hi Jakeoid,

Is this what you mean by "Console Output?"
Also, I just noticed it says something about “Something went wrong! Are you sure you have already generated an API key?” but it says the same thing even on the chrome profile where “Real Numbers” works, not that this shouldn’t be cause for concern.

// ==UserScript==
// @name WaniKani Real Numbers
// @namespace Mempo.scripts
// @author Mempo
// @description Replaces 42+ with the real number using WaniKani API
// @include http://www.wanikani.com/*
// @include https://www.wanikani.com/*
// @version 4
// @grant none
// @run-at document-end
// ==/UserScript==

function main() {
console.log(‘START OF WRN’);
var apiKey = localStorage.getItem(‘apiKey’);
if (!apiKey) {
if (window.location.href.indexOf(‘account’) != - 1) {
retrieveAPIkey();
apiKey = localStorage.getItem(‘apiKey’);
} else {
var okcancel = confirm(‘WaniKani Real Numbers has no API key entered!\nPress OK to go to your settings page and retrieve your API key!’);
if (okcancel == true) {
window.location = ‘https://www.wanikani.com/settings/account’;
}
}
}

var doneReviews = Boolean(localStorage.getItem(‘WRN_doneReviews’) || true);
var lastUpdate = Number(localStorage.getItem(‘WRN_lastUpdate’) || 0);
var currentTime = new Date().getTime();
if ((currentTime - lastUpdate) > 120000) {
localStorage.setItem(‘WRN_lastUpdate’, currentTime.toString());
doneReviews = true;
}
if (window.location.href.indexOf(‘review’) != - 1 || window.location.href.indexOf(‘lesson’) != - 1) {
localStorage.setItem(‘WRN_doneReviews’, “true”);
} else {
var numberReviews = document.getElementsByClassName(‘reviews’) [0].getElementsByTagName(‘span’) [0];
var numberLessons = document.getElementsByClassName(‘lessons’) [0].getElementsByTagName(‘span’) [0];
if (numberReviews.innerHTML == ‘42+’ || numberLessons.innerHTML == ‘42+’) {
if (apiKey) {
if (doneReviews) {
$.getJSON(‘https://www.wanikani.com/api/user/’ + apiKey + ‘/study-queue’, function (data) {
setTimeout(function () {
if (data.error) {
alert('API Error: ’ + data.error.message);
} else {
localStorage.setItem(‘WRN_numberReviews’, data.requested_information.reviews_available);
localStorage.setItem(‘WRN_numberLessons’, data.requested_information.lessons_available);
localStorage.setItem(‘WRN_doneReviews’, “”);
displayReal(numberReviews, numberLessons);
}
}, 0);
});
} else {
displayReal(numberReviews, numberLessons);
}
}
}
}
}
window.addEventListener(‘load’, main, false);

function retrieveAPIkey() {
apiKey = document.getElementById(‘user_api_key’).value;

if (apiKey) {
alert('WaniKani Real Numbers API key set to: ’ + apiKey);
localStorage.setItem(‘apiKey’, apiKey);
localStorage.setItem(‘WRN_doneReviews’, ‘true’);
}else{
alert(‘Something went wrong! Are you sure you have already generated an API key? If you have, try generating a new one. Hopefully that will solve the problem!’);
}
}

function displayReal(numberReviews, numberLessons) {
numberReviews.innerHTML = localStorage.getItem(‘WRN_numberReviews’);
numberLessons.innerHTML = localStorage.getItem(‘WRN_numberLessons’);
}


#4

Yeah, no… thats the script itself. CTRL + SHIFT + I should open a menu at the bottom of the page and pressing console and sharing the output of that would help greatly.