(function() {
'use strict';
const remove = selector => (
selector = document.querySelector(selector),
selector && selector.parentNode && selector.parentNode.removeChild(selector)
);
remove('script[src*="pointfour.github.io"]');
remove('script[src*="sheeptester.github.io"]');
const content = document.querySelector('table tr:nth-child(2) td:last-child'),
pageName = document.querySelector('title'),
path = window.location.pathname,
page = {
set title(tabName) {
pageName.textContent = 'Gamepro5 - ' + tabName;
},
get topify() {
content.vAlign = 'top';
},
swapLink(oldLink, newLink) {
document.querySelectorAll(`a[href="${oldLink}"]`).forEach(el => el.href = newLink);
}
};
page.swapLink('https://goo.gl/forms/tj4LqFKzyMPuOlqg1', 'https://goo.gl/forms/EeA1rGx8marT03MB3');
page.swapLink('https://goo.gl/forms/ziifb6S4XmK0k3QS2', 'https://goo.gl/forms/AOE4M5FjmbfvbTis2');
let customButtons = 0;
function button(text, onclick = '#') {
if (typeof onclick === 'string') {
return `${text}`
} else if (typeof onclick === 'function') {
let fnName = btoa(customButtons++).replace(/[^a-z]/gi, '') || 'a' + customButtons;
window[fnName] = () => onclick();
return ``
}
}
if (path.startsWith('/programs')) {
function newProgram(title, description, url) {
const id = title.toLowerCase().replace(/\s/g, '_');
if (path === '/programs/' + id) {
page.title = 'Programs';
content.innerHTML = `
${title}
${description ? `${description}
` : ''}
`;
} else if (path[9] !== '/') {
content.appendChild(document.createElement('p')).innerHTML = `
${title}
${button('play', '/programs/' + id)}
`;
}
}
// ====== CUSTOM PROGRAMS ======
// newProgram('test', 'hmmm', 'https://sheeptester.github.io/');
}
else switch (path) {
case '/':
function newNotif(title) {
const wrapper = document.createElement('center');
const id = atob(title).replace(/[^a-z]/gi, '') || 'a' + content.textContent.length;
if (localStorage[id] === 'yes') wrapper.style.display = 'none';
content.insertBefore(wrapper, content.querySelector('center:nth-of-type(2)'));
return {
set innerHTML(html) {
wrapper.innerHTML = `
×
${title}
${html}
`;
}
}
}
// ====== CUSTOM ALERTS ======
// newNotif('test').innerHTML = `lollololollol`;
break;
case '/news':
case '/news_list':
const list = path === '/news_list';
const postLinks = content.querySelector('td > center');
const posts = content.querySelector('.shadow');
function newPost(title, date) {
const id = title.replace(/\s/g, '_').replace(/[^a-z_]/gi, '');
if (!list)
postLinks.insertBefore(document.createElement('p'), postLinks.firstElementChild)
.innerHTML = `${id}`;
return {
set innerHTML(html) {
const post = document.createElement('div');
post.innerHTML = `${formatDate(date)}
`
+ `${title}
`
+ html;
if (list) {
post.insertBefore(document.createElement('hr'), post.firstElementChild)
.color = 'red';
content.insertBefore(post, content.querySelector('hr'));
} else {
post.className = 'popup';
post.id = id;
posts.appendChild(post);
}
}
}
}
const days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
const months = ['January', 'February', 'March', 'April', 'May', 'June',
'July', 'August', 'September', 'October', 'November', 'December'];
function formatDate(date) {
return `${days[date.getDay()]}, ${months[date.getMonth()]} ${date.getDate()}, ${date.getFullYear()}`
}
// ====== CUSTOM POSTS ======
// newPost('Title', new Date()).innerHTML = ``;
break;
case '/is-gamepro5-good-programmer':
page.title = 'Is Gamekeeper 5 a gud programer?';
content.innerHTML = `
Is Gamekeeper 5 a gud programer?
NO!
${button('why?', '/about-website?programing')}
`;
break;
case '/about-website':
if (window.location.search === '?programing') {
const paragraph = content.querySelector('p');
paragraph.innerHTML = paragraph.innerHTML
.replace('This site is by far my greatest accomplishment.', '$&');
document.head.appendChild(document.createElement('style')).textContent = `
x-highlight {
background-color: rgba(255, 0, 0, 0.1);
font-weight: bold;
/* border-bottom: 2px dashed red; */
}
`;
}
break;
}
}());