Ok, I've tried mrkgnao's suggestion to show 10 games per page so I could have more pages, and I was able to go right up to page 12 and back no problem, no errors and all games showing as far as I could tell. Last pages was empty (but there should only have been 11 pages, so that was fine and presumably just an error in my implementation of less games per page).
Trying to use mrkgnao's output of his games list to fool GoG into thinking I had more games... kind of worked. But it (somehow, I have no idea where it checked it) knew which games I did and didn't actually own and most of the library was just blank grey boxes so it was hard to tell what was and wasn't working.
So basically (yet again) I'm completely unable to reproduce the bug myself to try and get to the bottom of it.
I do remember having this duplicate problem before, when I was first trying to implement the games per page options, but can't quite remember what the issue was then (I think it was not emptying the arrays, which I seem to be doing right this time)
As I see it there are three possible places the problem could occur:
1) The games are retrieved from GoG's server. For non-manual sort each 100 game page is saved as a separate object with it's page number, so they are sorted correctly and there is no chance of duplicates. For manual sort I have to combine all the games to one array so I can sort them and it's possible that there is some problem here that is meaning games get added twice.
But looking through foxworks and mrkgnao's raw lists neither shows duplicates, so right now that's not a likely culprit.
2) The games are sorted. I can't quite see why or how this could cause duplication... but I'm not ruling it out. It could be there is an error somewhere in the sort function (though it's quite straight forward) or that the next bit is happening mid sort (again, this really shouldn't be happening) so that a game is placed and then moved and placed again (still shouldn't cause the error, but possibly a game appearing on multiple pages...)
I don't really see how this can be the problem, but if someone wouldn't mind checking by commenting out line 2766 (document.dispatchEvent(new Event("manualSortEvent"));) and running through the pages of their library I'd be grateful. This will stop the games actually being sorted (so expect them to be in the currently selected GoG sort order), while still doing all the other behind the scenes parts which may be an issue.
3) The games are sliced from the sorted array into separate page arrays (similar to how they are originally created in non manual sort). This seems the likely cause of issues, though again I can't quite see why as the arrays are dumped and recreated before the operation occurs and as only one slice occurs per object I can't see why it would make duplicates, unless I'm missing something.
I don't suppose there's some kind of test account I could use with access to the full library (minus the ability to download obviously) so I might actually be able to find a see these errors myself?