-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathspotify-storage-ben.html
More file actions
80 lines (71 loc) · 2.65 KB
/
spotify-storage-ben.html
File metadata and controls
80 lines (71 loc) · 2.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<html>
<body>
<p id="dummy"></p>
<script>
document.domain = 'websnapins.com'; // should be top-level domain e.g. spotify.com
//browser detection
var eswSafariFix = {};
eswSafariFix['getSafariType'] = function() {
var userAgent = navigator.userAgent.toLowerCase();
if(userAgent.indexOf("chrome") === -1 && userAgent.indexOf("safari") !== -1) {
if(userAgent.indexOf("mobile") === -1) {
return "desktop";
} else {
return "mobile";
}
}
return "none";
};
// Account for Safari cache quirks.
window.addEventListener("pageshow", function() {
if(eswSafariFix.getSafariType() === "desktop" && event.persisted) window.location.reload();
}, false);
//set browser-specific handlers
document.domain = 'websnapins.com';
var unloadEvt = eswSafariFix.getSafariType() !== 'none' ? "pagehide" : "beforeunload";
var onloadEvt = eswSafariFix.getSafariType() !== 'none' ? "pageshow" : "load";
function storeSessionData(key, data) {
if(data){
sessionStorage.setItem(key, data);
}else{
removeSessionData(key);
}
}
function getSessionData(key, data) {
return sessionStorage.getItem(key);
}
function removeSessionData(key) {
return sessionStorage.removeItem(key);
}
function createCookie(name,value,minutes) {
var expires = "";
if (minutes) {
var date = new Date();
date.setTime(date.getTime() + (minutes*60*1000));
expires = "; expires=" + date.toUTCString();
}
document.cookie = name + "=" + value + expires + "; path=/";
}
function readCookie(name) {
var nameEQ = name + "=";
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,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
function eraseCookie(name) {
createCookie(name,"",-1);
}
var unloadEvt = eswSafariFix.getSafariType() !== 'none' ? "pagehide" : "beforeunload";
var onloadEvt = eswSafariFix.getSafariType() !== 'none' ? "pageshow" : "load";
var onPageLoad = function (event) {
var targetorigin = 'http://' + parent.location.hostname;
parent.postMessage("storage_iframe_initialized", targetorigin);
};
window.addEventListener(onloadEvt, onPageLoad);
</script>
</body>
</html>