From d8d0209370bf0df31b09ef652122c7804a827668 Mon Sep 17 00:00:00 2001 From: max104t Date: Wed, 29 Jan 2020 11:19:56 -0800 Subject: [PATCH] Issue #73 : download settings as JSON file --- Periscope_Web_Client.user.js | 45 +++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/Periscope_Web_Client.user.js b/Periscope_Web_Client.user.js index a2a02d0..5a62420 100644 --- a/Periscope_Web_Client.user.js +++ b/Periscope_Web_Client.user.js @@ -417,6 +417,47 @@ var Notifications = { } } }; +function getTimeStamp() { + const date = new Date(); + const year = date.getFullYear(); + const month = `${date.getMonth() + 1}`.padStart(2, '0'); + const day =`${date.getDate()}`.padStart(2, '0'); + const h = `${date.getHours()}`.padStart(2, '0'); + const m = `${date.getMinutes()}`.padStart(2, '0'); + const s = `${date.getSeconds()}`.padStart(2, '0'); + return `${year}${month}${day}${h}${m}${s}`; +}; +function download_settings() { + const ts = getTimeStamp(); + const loginTwitter = JSON.parse(localStorage.getItem('loginTwitter')) || {}; + const user_name = loginTwitter["user"]["username"] || "settings"; + var filename = `${user_name}_${ts}.json`; + var data = []; + for(var i=0;iPeriscope settings'); var PeriSettings = $('
').append(settingsContainer, "
", buttonSettings); + var saveSettingsButton = $('Download Settings').click(function () {download_settings();}); $('#right').append($('
').append( ProfileEditSpoiler, ProfileEdit, MyOpSettingsSpoiler, MyOpSettings, NamesEditorSpoiler, NamesEditor, - PeriSettingsSpoiler, PeriSettings + PeriSettingsSpoiler, PeriSettings, + saveSettingsButton )); $(".spoiler").off("click").spoiler({ triggerEvents: true }); MyOpSettingsSpoiler.click();