Retrieving localstorage values in addon

You will have to wrap your JS code in a function or IIFE to return from it, otherwise you’ll get an Illegal return statement error and, due to that, a null return on the Python side.

(to see these errors, I would highly recommend either executing Anki from a terminal and looking at its output, or – for JS errors – debugging via AnkiWebView Inspector or Chrome remote debugging)