[Userscript]: Reorder Ultimate 2 [newest]

Context: Input box changes text to hiragana for radicals - #7 by Adi-M

@rfindley sorry for the trouble. There was a change the to subject objects delivered in the payload which broke the script.

Namely there is a change to the rad property. In the past we would either assign the radical’s character or the radical’s image filename as the value. We have introduced a new property called character_image_url where the value is the full url to the image. This led to reducing the rad role of only having the character as the value. If the character is not present, then it is null. So the expectation that rad value is always truthy is no longer there…

Scanning the scripts code there is a lot of logic which checks the truthiness of rad’s value. Given the change we made on our end, it broke the script.

The solution to this is to replace any truthy checks by checking the existence of the rad key. I recommend using Object.prototype.hasOwnProperty.call(object, property). Using an example, if one had a if (item.rad) {...}, it’ll need to be replaced with if (Object.prototype.hasOwnProperty.call(item, 'rad')) {...}.

This change should address the breaking.

Again, sorry for the inconvenience.

5 Likes