https://prnt.sc/ scroller
by FGRibreau
HTML
<h1>https://prnt.sc/ scroller</h1>
<input type="text" value="https://prnt.sc/mvhyur">
<button onclick="loadNext()">Next</button>
JavaScript
const iptUrl = document.querySelector('input');
const iframe = document.querySelector('iframe');
window.loadNext = () => {
let url = iptUrl.value;
let parts = url.split('/');
const id = _.last(parts);
const newUrl = _.without(parts, id).concat(nextId(id)).join('/');
iptUrl.value = newUrl;
window.open(newUrl);
}
function nextId(id){
console.log('next id', id);
return id.split('').reduceRight((memo, char) => {
if(memo.shouldInc){
const c = nextChar(char);
memo.output = c + memo.output;
console.log(memo.output);
memo.shouldInc = c === 'a';
} else {
memo.output = char + memo.output;
}
return memo;
}, {
shouldInc: true,
output: ''
}).output;
}
function nextChar(c) {
const next = String.fromCharCode(c.charCodeAt(0) + 1);
return next === '{' ? 'a' : next;
}
window.nextId = nextId;