openfoodfacts / power-user-script

User script for your browser, to empower Open Food Facts contribution
GNU Affero General Public License v3.0
12 stars 5 forks source link

Power User Script fails with the error `history is null` #90

Closed fgierlinger closed 7 months ago

fgierlinger commented 7 months ago

What

The power user script fails with the error "history is null". On line 804 the variable history should be assigned with the #history element, but the is none such in the DOM of e.g. https://world.openfoodfacts.org/product/6111099000247

https://github.com/openfoodfacts/power-user-script/blob/41c39a50320ecc63776c4b5b2ffc7c4831d0c602/OpenFoodFactsPower.user.js#L829

Uncaught (in promise) TypeError: history is null
    window["__f__lsl0fzv4.kt9"]/</< moz-extension://b44e721e-003d-49fa-8d38-f046ab61ffb4/userscripts/Open-Food-Facts-power-user-script.user.js?id=fa8fc560-58ad-4b78-9bf9-c5916ff18b57:852
    window["__f__lsl0fzv4.kt9"]/< moz-extension://b44e721e-003d-49fa-8d38-f046ab61ffb4/userscripts/Open-Food-Facts-power-user-script.user.js?id=fa8fc560-58ad-4b78-9bf9-c5916ff18b57:2837
    Rt https://world.openfoodfacts.org/product/6111099000247:9
    window["__f__lsl0fzv4.kt9"]/< moz-extension://b44e721e-003d-49fa-8d38-f046ab61ffb4/userscripts/Open-Food-Facts-power-user-script.user.js?id=fa8fc560-58ad-4b78-9bf9-c5916ff18b57:1
    "__f__lsl0fzv4.kt9" moz-extension://b44e721e-003d-49fa-8d38-f046ab61ffb4/userscripts/Open-Food-Facts-power-user-script.user.js?id=fa8fc560-58ad-4b78-9bf9-c5916ff18b57:1
    Rt https://world.openfoodfacts.org/product/6111099000247:9
    o https://world.openfoodfacts.org/product/6111099000247:81
    <anonymous> https://world.openfoodfacts.org/product/6111099000247:84
    m https://world.openfoodfacts.org/product/6111099000247:78
6111099000247 line 9 > injectedScript:852:13

Steps to reproduce the behavior:

  1. Go to https://world.openfoodfacts.org/product/6111099000247
  2. Open Web Developer Tools and inspect the error
  3. Try to get DOM by manually executing document.getElementById("history") in the web console. null is returned.

Expected behavior

Power User Script should work in all cases

Platform (Desktop, Mobile, Hunger Games)

CharlesNepote commented 7 months ago

Fixed, thanks for the report.