blob: f16974e8e48b0f31a7f2a082acb4b4c7cae45f08 [file] [log] [blame]
import {getOptions} from '../common/optionsUtils.js';
var CCThreadWithoutMessage = /forum\/[0-9]*\/thread\/[0-9]*$/;
const kLoadMoreButtons = [
{
feature: 'thread',
buttonSelectors: [
'.thread-all-replies__load-more-button',
'.scTailwindThreadMorebuttonload-more .scTailwindThreadMorebuttonbutton',
],
},
{
feature: 'threadall',
buttonSelectors: [
'.thread-all-replies__load-all-button',
'.scTailwindThreadMorebuttonload-all .scTailwindThreadMorebuttonbutton',
],
}
];
var intersectionObserver;
function intersectionCallback(entries, observer) {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.click();
}
});
};
var intersectionOptions = {
threshold: 1.0,
};
getOptions(null).then(options => {
var redirectLink = document.querySelector('.community-console');
if (options.redirect && redirectLink !== null) {
var redirectUrl = redirectLink.href;
var searchParams = new URLSearchParams(location.search);
if (searchParams.has('msgid') && searchParams.get('msgid') !== '' &&
CCThreadWithoutMessage.test(redirectUrl))
redirectUrl +=
'/message/' + encodeURIComponent(searchParams.get('msgid'));
window.location = redirectUrl;
} else {
for (const entry of kLoadMoreButtons)
if (options[entry.feature])
for (const selector of entry.buttonSelectors) {
let button = document.querySelector(selector);
if (button !== null) {
intersectionObserver = new IntersectionObserver(
intersectionCallback, intersectionOptions);
intersectionObserver.observe(button);
}
}
}
});