diff options
Diffstat (limited to 'src/assets')
-rw-r--r-- | src/assets/javascripts/helpers/general.js | 2 | ||||
-rw-r--r-- | src/assets/javascripts/helpers/imgur.js | 2 | ||||
-rw-r--r-- | src/assets/javascripts/helpers/twitter.js | 194 | ||||
-rw-r--r-- | src/assets/javascripts/helpers/wikipedia.js | 2 | ||||
-rw-r--r-- | src/assets/javascripts/helpers/youtube/options.js | 1 | ||||
-rw-r--r-- | src/assets/javascripts/helpers/youtube/youtube.js | 45 |
6 files changed, 180 insertions, 66 deletions
diff --git a/src/assets/javascripts/helpers/general.js b/src/assets/javascripts/helpers/general.js index 1ee6bcf5..9fec500f 100644 --- a/src/assets/javascripts/helpers/general.js +++ b/src/assets/javascripts/helpers/general.js @@ -65,7 +65,7 @@ async function init() { "popupFrontends", "autoRedirect" ], - r => { // r = result + r => { if (r.exceptions) exceptions = r.exceptions; alwaysUsePreferred = r.alwaysUsePreferred ?? false; diff --git a/src/assets/javascripts/helpers/imgur.js b/src/assets/javascripts/helpers/imgur.js index 91e30fde..c8c65159 100644 --- a/src/assets/javascripts/helpers/imgur.js +++ b/src/assets/javascripts/helpers/imgur.js @@ -171,7 +171,7 @@ async function init() { "imgurProtocol", ], - r => { // r = result + r => { disable = r.disableImgur ?? false; protocol = r.imgurProtocol ?? "normal"; diff --git a/src/assets/javascripts/helpers/twitter.js b/src/assets/javascripts/helpers/twitter.js index 64507a9f..a333777d 100644 --- a/src/assets/javascripts/helpers/twitter.js +++ b/src/assets/javascripts/helpers/twitter.js @@ -110,6 +110,59 @@ function setBypassWatchOnTwitter(val) { let alwaysUsePreferred; +let theme; +const getTheme = () => theme; + +let infiniteScroll; +const getInfiniteScroll = () => infiniteScroll; + +let stickyProfile; +const getStickyProfile = () => stickyProfile; + +let bidiSupport; +const getBidiSupport = () => bidiSupport; + +let hideTweetStats; +const getHideTweetStats = () => hideTweetStats; + +let hideBanner; +const getHideBanner = () => hideBanner; + +let hidePins; +const getHidePins = () => hidePins; + +let hideReplies; +const getHideReplies = () => hideReplies; + +let squareAvatars; +const getSquareAvatars = () => squareAvatars; + +let mp4Playback; +const getMp4Playback = () => mp4Playback; + +let hlsPlayback; +const getHlsPlayback = () => hlsPlayback; + +let proxyVideos; +const getProxyVideos = () => proxyVideos; + +let muteVideos; +const getMuteVideos = () => muteVideos; + +let autoplayGifs; +const getAutoplayGifs = () => autoplayGifs; + + + +async function setSettings(val) { + return new Promise( + resolve => { + browser.storage.local.set(val).then(resolve); + } + ) + +} + function redirect(url, initiator) { let protocolHost = commonHelper.protocolHost(url); let isNitter = [ @@ -224,32 +277,93 @@ function isNitter(url, type) { ].includes(protocolHost); } -let theme; let applyThemeToSites; function initNitterCookies() { - let themeValue; - if (theme == 'light') themeValue = 'Twitter'; - if (theme == 'dark') themeValue = 'Twitter Dark'; - if (applyThemeToSites && themeValue) { + if (enableCustomSettings) { let allInstances = [...redirects.nitter.normal, ...redirects.nitter.tor, ...nitterNormalCustomRedirects, ...nitterTorCustomRedirects] let checkedInstances = [...nitterNormalRedirectsChecks, ...nitterNormalCustomRedirects, ...nitterTorRedirectsChecks, ...nitterTorCustomRedirects] - for (const instanceUrl of allInstances) - if (!checkedInstances.includes(instanceUrl)) - browser.cookies.remove({ - url: instanceUrl, - name: "theme", - }) - for (const instanceUrl of checkedInstances) + for (const instanceUrl of allInstances) if (!checkedInstances.includes(instanceUrl)) + browser.cookies.remove({ + url: instanceUrl, + name: "theme", + }) + for (const instanceUrl of checkedInstances) { browser.cookies.set({ url: instanceUrl, name: "theme", - value: themeValue + value: theme, + }) + browser.cookies.set({ + url: instanceUrl, + name: "infiniteScroll", + value: infiniteScroll ? 'on' : '', }) + browser.cookies.set({ + url: instanceUrl, + name: "stickyProfile", + value: stickyProfile ? 'on' : '', + }) + browser.cookies.set({ + url: instanceUrl, + name: "bidiSupport", + value: bidiSupport ? 'on' : '', + }) + browser.cookies.set({ + url: instanceUrl, + name: "hideTweetStats", + value: hideTweetStats ? 'on' : '', + }) + browser.cookies.set({ + url: instanceUrl, + name: "hideBanner", + value: hideBanner ? 'on' : '', + }) + browser.cookies.set({ + url: instanceUrl, + name: "hidePins", + value: hidePins ? 'on' : '', + }) + browser.cookies.set({ + url: instanceUrl, + name: "hideReplies", + value: hideReplies ? 'on' : '', + }) + browser.cookies.set({ + url: instanceUrl, + name: "squareAvatars", + value: squareAvatars ? 'on' : '', + }) + browser.cookies.set({ + url: instanceUrl, + name: "mp4Playback", + value: mp4Playback ? 'on' : '', + }) + browser.cookies.set({ + url: instanceUrl, + name: "hlsPlayback", + value: hlsPlayback ? 'on' : '', + }) + browser.cookies.set({ + url: instanceUrl, + name: "proxyVideos", + value: proxyVideos ? 'on' : '', + }) + browser.cookies.set({ + url: instanceUrl, + name: "muteVideos", + value: muteVideos ? 'on' : '', + }) + browser.cookies.set({ + url: instanceUrl, + name: "autoplayGifs", + value: autoplayGifs ? 'on' : '', + }) + } } } async function init() { - return new Promise((resolve) => { + return new Promise(resolve => { fetch('/instances/data.json').then(response => response.text()).then(data => { let dataJson = JSON.parse(data); browser.storage.local.get( @@ -259,10 +373,6 @@ async function init() { "enableTwitterCustomSettings", "twitterRedirects", - - "theme", - "applyThemeToSites", - "bypassWatchOnTwitter", "nitterNormalRedirectsChecks", @@ -272,8 +382,22 @@ async function init() { "nitterTorCustomRedirects", "twitterProtocol", - "alwaysUsePreferred", + + "nitterTheme", + "nitterInfiniteScroll", + "nitterStickyProfile", + "nitterBidiSupport", + "nitterHideTweetStats", + "nitterHideBanner", + "nitterHidePins", + "nitterHideReplies", + "nitterSquareAvatars", + "nitterMp4Playback", + "nitterHlsPlayback", + "nitterProxyVideos", + "nitterMuteVideos", + "nitterAutoplayGifs", ], r => { disable = r.disableTwitter ?? false; @@ -297,6 +421,21 @@ async function init() { nitterTorRedirectsChecks = r.nitterTorRedirectsChecks ?? [...redirects.nitter.tor]; nitterTorCustomRedirects = r.nitterTorCustomRedirects ?? []; + theme = r.nitterTheme ?? 'Auto'; + infiniteScroll = r.nitterInfiniteScroll ?? false; + stickyProfile = r.nitterStickyProfile ?? true; + bidiSupport = r.nitterBidiSupport ?? false; + hideTweetStats = r.nitterHideTweetStats ?? false; + hideBanner = r.nitterHideBanner ?? false; + hidePins = r.nitterHidePins ?? false; + hideReplies = r.nitterHideReplies ?? false; + squareAvatars = r.nitterSquareAvatars ?? false; + mp4Playback = r.nitterMp4Playback ?? true; + hlsPlayback = r.nitterHlsPlayback ?? false; + proxyVideos = r.nitterProxyVideos ?? true; + muteVideos = r.nitterMuteVideos ?? false; + autoplayGifs = r.nitterAutoplayGifs ?? true; + initNitterCookies(); resolve(); @@ -340,6 +479,23 @@ export default { isNitter, initNitterCookies, + getTheme, + getInfiniteScroll, + getStickyProfile, + getBidiSupport, + getHideTweetStats, + getHideBanner, + getHidePins, + getHideReplies, + getSquareAvatars, + getMp4Playback, + getHlsPlayback, + getProxyVideos, + getMuteVideos, + getAutoplayGifs, + + setSettings, + redirect, init, switchInstance, diff --git a/src/assets/javascripts/helpers/wikipedia.js b/src/assets/javascripts/helpers/wikipedia.js index 7a4173fb..9e41f119 100644 --- a/src/assets/javascripts/helpers/wikipedia.js +++ b/src/assets/javascripts/helpers/wikipedia.js @@ -199,7 +199,7 @@ async function init() { "theme", "applyThemeToSites", - ], r => { // r = result + ], r => { disable = r.disableWikipedia ?? true; protocol = r.wikipediaProtocol ?? "normal"; diff --git a/src/assets/javascripts/helpers/youtube/options.js b/src/assets/javascripts/helpers/youtube/options.js index e044a82b..a4abd363 100644 --- a/src/assets/javascripts/helpers/youtube/options.js +++ b/src/assets/javascripts/helpers/youtube/options.js @@ -5,7 +5,6 @@ window.browser = window.browser || window.chrome; export let youtubeListen; export const getYoutubeListen = () => youtubeListen; - export let volume; export const getVolume = () => volume; export function setVolume(val) { diff --git a/src/assets/javascripts/helpers/youtube/youtube.js b/src/assets/javascripts/helpers/youtube/youtube.js index d51bf085..4de189b6 100644 --- a/src/assets/javascripts/helpers/youtube/youtube.js +++ b/src/assets/javascripts/helpers/youtube/youtube.js @@ -581,7 +581,7 @@ async function init() { "bypassWatchOnYoutube" ], - r => { // r = result + r => { redirects.invidious = dataJson.invidious; if (r.youtubeRedirects) redirects = r.youtubeRedirects; @@ -628,99 +628,58 @@ async function init() { export default { setYoutubeSettings, - getBypassWatchOnYoutube, - initPipedLocalStorage, initPipedMaterialLocalStorage, - getFrontend, - getYoutubeEmbedFrontend, - getRedirects, getCustomRedirects, setInvidiousRedirects, setPipedRedirects, - redirect, switchInstance, - isPipedorInvidious, - initInvidiousCookies, - getInvidiousAlwaysProxy, - getInvidiousQuality, - getInvidiousPlayerStyle, - getInvidiousVideoLoop, - + getDisable, setDisable, getEnableCustomSettings, - getProtocol, - getOnlyEmbeddedVideo, - setVolume, getVolume, - setAutoplay, getAutoplay, - getInvidiousContinueAutoplay, - getInvidiousContinue, - getYoutubeListen, - getInvidiousSpeed, - getInvidiousQualityDash, - getInvidiousComments, - getInvidiousCaptions, - getInvidiousRelatedVideos, - getInvidiousAnnotations, - getInvidiousExtendDesc, - getInvidiousVrMode, - getInvidiousSavePlayerPos, - getPipedBufferGoal, - getPipedComments, - getPipedDisableLBRY, - getPipedEnabledCodecs, - getPipedHomepage, - getPipedMinimizeDescription, - getPipedProxyLBRY, - getPipedQuality, - getPipedRegion, - getPipedSelectedSkip, - getPipedSponsorblock, - getPipedWatchHistory, - getPipedMaterialSkipToLastPoint, getInvidiousNormalRedirectsChecks, |