diff --git a/xExtension-YouTube/configure.phtml b/xExtension-YouTube/configure.phtml index 2a826a0..b9caf48 100644 --- a/xExtension-YouTube/configure.phtml +++ b/xExtension-YouTube/configure.phtml @@ -32,7 +32,7 @@ declare(strict_types=1);
diff --git a/xExtension-YouTube/extension.php b/xExtension-YouTube/extension.php index 33f9888..26b9484 100644 --- a/xExtension-YouTube/extension.php +++ b/xExtension-YouTube/extension.php @@ -517,7 +517,7 @@ final class YouTubeExtension extends Minz_Extension FreshRSS_Context::userConf()->_attribute('yt_player_width', Minz_Request::paramInt('yt_width')); FreshRSS_Context::userConf()->_attribute('yt_show_content', Minz_Request::paramBoolean('yt_show_content')); FreshRSS_Context::userConf()->_attribute('yt_download_channel_icons', Minz_Request::paramBoolean('yt_download_channel_icons')); - FreshRSS_Context::userConf()->_attribute('yt_nocookie', Minz_Request::paramInt('yt_nocookie')); + FreshRSS_Context::userConf()->_attribute('yt_nocookie', Minz_Request::paramBoolean('yt_nocookie')); FreshRSS_Context::userConf()->save(); } diff --git a/xExtension-YouTube/static/fetchIcons.js b/xExtension-YouTube/static/fetchIcons.js index 0157718..13dab27 100755 --- a/xExtension-YouTube/static/fetchIcons.js +++ b/xExtension-YouTube/static/fetchIcons.js @@ -1,15 +1,15 @@ 'use strict'; -/* globals context */ +/* globals context, slider */ function initFetchBtn() { + const i18n = context.extensions.yt_i18n; + const fetchIcons = document.querySelector('button[value="iconFetchFinish"]'); if (!fetchIcons) { return; } - const i18n = context.extensions.yt_i18n; - document.querySelectorAll('#yt_action_btn').forEach(el => el.style.marginBottom = '1rem'); fetchIcons.removeAttribute('disabled'); @@ -18,9 +18,15 @@ function initFetchBtn() { fetchIcons.onclick = function(e) { e.preventDefault(); + const closeSlider = document.querySelector('#close-slider'); + if (closeSlider) { + closeSlider.onclick = (e) => e.preventDefault(); + closeSlider.style.cursor = 'not-allowed'; + } + + fetchIcons.form.onsubmit = window.onbeforeunload = (e) => e.preventDefault(); fetchIcons.onclick = null; fetchIcons.disabled = true; - fetchIcons.form.onsubmit = (e) => e.preventDefault(); fetchIcons.parentElement.insertAdjacentHTML('afterend', `

@@ -34,7 +40,7 @@ function initFetchBtn() { const configureUrl = fetchIcons.form.action; function ajaxBody(action, args) { - return new URLSearchParams({ + return JSON.stringify({ '_csrf': context.csrf, 'yt_action_btn': 'ajax' + action, ...args @@ -42,10 +48,10 @@ function initFetchBtn() { } fetch(configureUrl, { - method: "POST", + method: 'POST', body: ajaxBody('GetYtFeeds'), headers: { - "Content-Type": "application/x-www-form-urlencoded" + 'Content-Type': 'application/json; charset=UTF-8' } }).then(resp => { if (!resp.ok) { @@ -56,17 +62,17 @@ function initFetchBtn() { let completed = 0; json.forEach(async (feed) => { await fetch(configureUrl, { - method: "POST", + method: 'POST', body: ajaxBody('FetchIcon', {'id': feed.id}), headers: { - "Content-Type": "application/x-www-form-urlencoded" + 'Content-Type': 'application/json; charset=UTF-8' } }).then(async () => { iconFetchChannel.innerText = feed.title; iconFetchCount.innerText = `${++completed}/${json.length}`; if (completed === json.length) { fetchIcons.disabled = false; - fetchIcons.form.onsubmit = null; + fetchIcons.form.onsubmit = window.onbeforeunload = null; fetchIcons.click(); } }); @@ -76,8 +82,8 @@ function initFetchBtn() { } window.addEventListener('load', function() { - if (document.querySelector('#slider')) { - document.querySelector('#slider').addEventListener('freshrss:slider-load', initFetchBtn); + if (typeof slider !== 'undefined') { + slider.addEventListener('freshrss:slider-load', initFetchBtn); } initFetchBtn(); });