@@ -2,6 +2,7 @@ import type { LocaleData, Options, VersionJSON } from './type'
22import {
33 CUSTOM_UPDATE_EVENT_NAME ,
44 DIRECTORY_NAME ,
5+ INJECT_SCRIPT_TAG_ID ,
56 JSON_FILE_NAME ,
67 LOCAL_STORAGE_PREFIX ,
78 NOTIFICATION_ANCHOR_CLASS_NAME ,
@@ -64,6 +65,21 @@ window.pluginWebUpdateNotice_ = {
6465 } ,
6566}
6667
68+ /**
69+ * Get the version from the script tag
70+ */
71+ function getLocaleVersion ( ) {
72+ const script = document . querySelector ( `script[data-id="${ INJECT_SCRIPT_TAG_ID } "]` )
73+ if ( ! script )
74+ return ''
75+ const version = script . getAttribute ( 'data-v' )
76+ if ( ! version )
77+ return ''
78+
79+ window . pluginWebUpdateNotice_version = version
80+ return version
81+ }
82+
6783/**
6884 * It checks whether the system has been updated and if so, it shows a notification.
6985 * @param {Options } options - Options
@@ -78,6 +94,7 @@ function __checkUpdateSetup__(options: Options) {
7894 checkOnLoadFileError = true ,
7995 } = options
8096 const checkSystemUpdate = ( ) => {
97+ const localeVersion = getLocaleVersion ( )
8198 window
8299 . fetch ( `${ injectFileBase } ${ DIRECTORY_NAME } /${ JSON_FILE_NAME } .json?t=${ Date . now ( ) } ` )
83100 . then ( ( response ) => {
@@ -90,7 +107,7 @@ function __checkUpdateSetup__(options: Options) {
90107 if ( silence )
91108 return
92109 latestVersion = versionFromServer
93- if ( window . pluginWebUpdateNotice_version !== versionFromServer ) {
110+ if ( localeVersion !== versionFromServer ) {
94111 // dispatch custom event
95112 document . body . dispatchEvent ( new CustomEvent ( CUSTOM_UPDATE_EVENT_NAME , {
96113 detail : {
0 commit comments