Data in cookies is limited to 4KB and localStorage can be used instead to store larger data that persists between sessions.
I have tested a modification to AGKPlayer.js to allow access to localStorage
unminify, then replace
{
var cookieName = UTF8ToString($0);
var cookieValue = UTF8ToString($1);
var d = new Date;
d.setTime(d.getTime() + 5 * 365 * 24 * 60 * 60 * 1e3);
var expires = "expires=" + d.toUTCString();
document.cookie = cookieName + "=" + cookieValue + ";" + expires + ";path=/"
}
}), (function($0, $1) {
{
var cookieName = UTF8ToString($0);
var returnValue = UTF8ToString($1);
var name = cookieName + "=";
var ca = document.cookie.split(";");
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == " ") {
c = c.substring(1)
}
if (c.indexOf(name) == 0) {
returnValue = c.substring(name.length, c.length);
break
}
}
var lengthBytes = lengthBytesUTF8(returnValue) + 1;
var heapString = _malloc(lengthBytes);
stringToUTF8(returnValue, heapString, lengthBytes);
return heapString
}
}), (function($0) {
{
var cookieName = UTF8ToString($0);
document.cookie = cookieName + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/"
}
with
{
var cookieName = UTF8ToString($0);
var cookieValue = UTF8ToString($1);
var d = new Date;
if (cookieName.indexOf( "_ls" ) == 0)
{
localStorage.setItem( cookieName, cookieValue )
}
else
{
d.setTime(d.getTime() + 5 * 365 * 24 * 60 * 60 * 1e3);
var expires = "expires=" + d.toUTCString();
document.cookie = cookieName + "=" + cookieValue + ";" + expires + ";path=/"
}
}
}), (function($0, $1) {
{
var cookieName = UTF8ToString($0);
var returnValue = UTF8ToString($1);
var name = cookieName + "=";
var ca = document.cookie.split(";");
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == " ") {
c = c.substring(1)
}
if (c.indexOf(name) == 0) {
returnValue = c.substring(name.length, c.length);
break
}
}
if (cookieName === "args")
{
returnValue = window.location.href
}
if (cookieName.indexOf( "_ls" ) == 0)
{
returnValue = localStorage.getItem( cookieName )
if (!returnValue) returnValue = ""
}
var lengthBytes = lengthBytesUTF8(returnValue) + 1;
var heapString = _malloc(lengthBytes);
stringToUTF8(returnValue, heapString, lengthBytes);
return heapString
}
}), (function($0) {
{
var cookieName = UTF8ToString($0);
if (cookieName.indexOf( "_ls" ) == 0)
{
localStorage.removeItem( cookieName )
}
else
{
document.cookie = cookieName + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/"
}
}
as you can see, any shared variable starting with _ls will then be redirected to localStorage, so you might have functions like these
function Profile_ReadString( name$ as string )
data$ as string
if CompareString( "html5", GetDeviceBaseName()) // use shared variable
data$ = LoadSharedVariable( "_ls" + name$, "" ) // _ls = localStorage
elseif GetFileExists( name$ ) // use file
id = OpenToRead( name$ )
data$ = ReadString( id )
CloseFile( id )
endif
endfunction data$
function Profile_WriteString( name$ as string, data$ as string )
if not len( data$ )
Profile_DeleteString( name$ )
exitfunction
endif
if CompareString( "html5", GetDeviceBaseName()) // use shared variable
SaveSharedVariable( "_ls" + name$, data$ ) // _ls = localStorage
else // use file
id = OpenToWrite( name$, 0 )
WriteString( id, data$ )
CloseFile( id )
endif
endfunction
function Profile_DeleteString( name$ as string )
if CompareString( "html5", GetDeviceBaseName()) // use shared variable
DeleteSharedVariable( "_ls" + name$ ) // _ls = localStorage
elseif GetFileExists( name$ ) // use file
DeleteFile( name$ )
endif
endfunction
to use files normally or localStorage if you export to Html5