-
-
Save iiic/016231fd4828d71654debda1ebd06a76 to your computer and use it in GitHub Desktop.
Flash message _fid parameter remove.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function (w) { | |
'use strict'; | |
const TIMEOUT = 2000; | |
const FID_QSA = '_fid='; | |
function removeFid() { | |
var url = w.location.search.toString(); | |
var fidPosition = url.indexOf(FID_QSA); | |
if (w.history && w.history.replaceState && fidPosition !== -1) { | |
var repairedUrl = url.substr(0, fidPosition) + url.substr(fidPosition + 10); | |
while ((repairedUrl.substr(repairedUrl.length-1) === '?') || (repairedUrl.substr(repairedUrl.length-1) === '&')) { | |
repairedUrl = repairedUrl.substr(0, repairedUrl.length-1); | |
} | |
w.history.replaceState({}, null, w.location.pathname.toString() + repairedUrl + w.location.hash); | |
} | |
return true; | |
} | |
w.addEventListener('beforeunload', removeFid); | |
setTimeout(removeFid, TIMEOUT); | |
}(window)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment