36 lines
No EOL
1.4 KiB
JavaScript
36 lines
No EOL
1.4 KiB
JavaScript
// ==UserScript==
|
|
// @match https://next.ink/*
|
|
// @name Enhancements for next.ink
|
|
// @description Enhancements for next.ink
|
|
// @grant none
|
|
// @version 0.1.0
|
|
// @author KaKi87
|
|
// @license MIT
|
|
// @namespace https://git.kaki87.net/KaKi87/userscripts/src/branch/master/enhancementsForNextInk
|
|
// ==/UserScript==
|
|
|
|
(async () => {
|
|
for(const postElement of document.querySelectorAll('[data-post-id]')){
|
|
const
|
|
postId = postElement.getAttribute('data-post-id'),
|
|
postDocument = await Promise
|
|
.resolve(new URL(window.location.href).origin)
|
|
.then(_ => fetch(`${_}/${postId}/`))
|
|
.then(_ => _.text())
|
|
.then(_ => new DOMParser().parseFromString(_, 'text/html')),
|
|
isPremium = !!postDocument.querySelector('.next-have-paywall-content'),
|
|
indicatorElement = document.createElement('div');
|
|
postElement.style['position'] = 'relative';
|
|
indicatorElement.innerHTML = `
|
|
<div
|
|
class="next-post-categorie"
|
|
style="position: absolute; top: 0; right: 0;"
|
|
>
|
|
<span class="next-categories-button">
|
|
${isPremium ? 'Premium' : 'Free'}
|
|
</span>
|
|
</div>
|
|
`;
|
|
postElement.insertAdjacentElement('afterbegin', indicatorElement);
|
|
}
|
|
})().catch(console.error); |