theCrius / tildes-extended

Extension for Chrome and Firefox to enhance the UX/UI of https://tildes.net
ISC License
14 stars 5 forks source link

Add automatic update of external CSS sources #34

Closed theCrius closed 6 years ago

theCrius commented 6 years ago

@Bauke can you give it a try before I merge it back into develop?

Seems fine to me to be honest. The logic is simple enough.

On options, the first time this will be released, it will check for the customCss feature. If it's enabled it will add a new field "lastPull" in the settings that is a timestamp in ms.

From that moment and on, when the feature is enabled, the lastPull is updated with the timestamp of when it was enabled.

In the script that apply the custom CSS, everytime it loads (so effectively when it's needed), before applying the script we check for:

If all these conditions are truthy, I ran an asynchronous request for every external URL I get, once completed, update the localstorage with the new source and apply it to the page. Also updating the lastPull with the new timestamp.