diff --git a/css/specific.css b/css/specific.css index 963f529..c47950e 100755 --- a/css/specific.css +++ b/css/specific.css @@ -11,7 +11,7 @@ body[data-URL^="https://polytoria.com/create/"] .col.d-flex.align-content-betwee } .text-truncate { - white-space: nowrap !important; /* Prevents text from wrapping to the next line */ - overflow: hidden !important; /* Hides the overflowing text */ - text-overflow: ellipsis !important; /* Adds an ellipsis (...) to indicate truncated text */ + white-space: nowrap !important; + overflow: hidden !important; + text-overflow: ellipsis !important; } \ No newline at end of file diff --git a/js/account/create.js b/js/account/create.js deleted file mode 100755 index bcd28ab..0000000 --- a/js/account/create.js +++ /dev/null @@ -1,7 +0,0 @@ -let NavColumn = document.getElementsByClassName('col-lg-2')[0] -let LaunchCreatorBtn = document.createElement('button') -LaunchCreatorBtn.classList = 'btn btn-success w-100' -LaunchCreatorBtn.innerText = 'Launch Creator' -LaunchCreatorBtn.setAttribute('data-id', '1') -LaunchCreatorBtn.setAttribute('onclick', 'editPlace(this)') -NavColumn.appendChild(LaunchCreatorBtn) \ No newline at end of file diff --git a/js/account/inbox.js b/js/account/inbox.js new file mode 100644 index 0000000..f5324d4 --- /dev/null +++ b/js/account/inbox.js @@ -0,0 +1,47 @@ +HandleExpandMessages() + +function HandleExpandMessages() { + const Messages = document.getElementById('messages') + + for (let message of Messages.children) { + let Expanded = false + let ContentDiv = null + + const ViewButton = message.querySelector('a.btn[href^="/inbox/messages"]') + const MessageID = ViewButton.getAttribute('href').split('/')[3] + + const ExpandButton = document.createElement('button') + ExpandButton.classList = 'btn btn-outline-warning px-4 mt-1' + ExpandButton.innerText = 'Expand' + ViewButton.parentElement.appendChild(ExpandButton) + + ExpandButton.addEventListener('click', function(){ + if (ContentDiv === null) { + fetch('https://polytoria.com/inbox/messages/'+MessageID) + .then(response => { + if (!response.ok) { + throw new Error('Network not ok') + } + return response.text() + }) + .then(data => { + const Doc = new DOMParser().parseFromString(data, 'text/html') + const MessageContent = Doc.querySelector('p.mb-0').innerText + + ContentDiv = document.createElement('div') + ContentDiv.classList = 'py-2' + ContentDiv.innerText = MessageContent + message.appendChild(ContentDiv) + }) + .catch(error => { + console.log(error) + }); + } + + Expanded = !Expanded + + ExpandButton.innerText = (Expanded === false) ? 'Expand' : 'Minimize' + ContentDiv.style.display = (Expanded === false) ? 'none' : 'block' + }); + } +} \ No newline at end of file diff --git a/js/background.js b/js/background.js index 3c3b1ba..44cccfc 100755 --- a/js/background.js +++ b/js/background.js @@ -1,3 +1,57 @@ +const Manifest = chrome.runtime.getManifest() + +// WHEN CLICKING ON EXTENSION ICON OPEN THE SETTINGS PAGE +chrome.action.onClicked.addListener((tab) => { + chrome.tabs.create({ active: true, url: chrome.runtime.getURL('settings.html') }); +}); + +// REGISTER AN ALARM FOR DAILY UPDATE CHECK +/* +chrome.alarms.create("PolyPlus-UpdateCheck", { + periodInMinutes: 24 * 60, + when: Date.now() + (12 - new Date().getHours()) * 60 * 60 * 1000, +}); +*/ + +// Create a date object with the current date and the desired time +/* +var date = new Date(); +date.setHours(19, 31, 0, 0); // 7:25 PM + +// Create an alarm that fires at 7:25 PM and repeats every day +chrome.alarms.create("PolyPlus-UpdateCheck", { + periodInMinutes: 24 * 60, + when: date.getTime() +}); +*/ + + +// HANDLE ALARMS FIRING +chrome.alarms.onAlarm.addListener(function(alarm){ + if (alarm.name === 'PolyPlus-UpdateCheck') { + fetch('https://polyplus.vercel.app/data/version.json') + .then(response => { + if (!response.ok) { + throw new Error('Network not ok') + } + return response.json() + }) + .then(data => { + if (data.version > Manifest.version) { + console.log('Update available') + chrome.notifications.create({ + type: "basic", + iconUrl: chrome.runtime.getURL("icon.png"), + title: "New Update Available", + message: "A new update is available for Poly+!", + }) + } + }) + .catch(error => {console.log(error)}) + } +}); + +// COPY ASSET ID CONTEXT MENU ITEM REGISTRATION chrome.contextMenus.create({ title: 'Copy Asset ID', id: 'PolyPlus-CopyID', @@ -10,6 +64,7 @@ chrome.contextMenus.create({ ] }); +// COPY AVATAR HASH CONTEXT MENU ITEM REGISTRATION chrome.contextMenus.create({ title: 'Copy Avatar Hash', id: 'PolyPlus-CopyAvatarHash', @@ -21,6 +76,7 @@ chrome.contextMenus.create({ ] }); +// HANDLE CONTEXT MENU ITEMS chrome.contextMenus.onClicked.addListener(function (info, tab){ if (info.menuItemId === 'PolyPlus-CopyID') { let ID = parseInt(info.linkUrl.split('/')[4]) @@ -45,21 +101,6 @@ chrome.contextMenus.onClicked.addListener(function (info, tab){ } }); -/* -chrome.webNavigation.onCompleted.addListener(function (details){ - console.log('TAB CREATED') - - chrome.scripting - .executeScript({ - target: {tabId: details.tabId}, - func: HandleJoinPlace, - args: [details.url] - }) -}, { - url: [{ urlMatches: "https://polytoria.com/join-place/*" }] -}); -*/ - function CopyAssetID(id) { navigator.clipboard .writeText(id) @@ -102,4 +143,8 @@ function HandleJoinPlace(url) { window.location.href = 'polytoria://client/' + data.token }) .catch(error => {console.log(error)}) +} + +export default { + hi: 1 } \ No newline at end of file diff --git a/js/debug.js b/js/debug.js new file mode 100644 index 0000000..d28ace0 --- /dev/null +++ b/js/debug.js @@ -0,0 +1,53 @@ +// DEBUG MENU FOR CLEARING PINNED GAMES AND BEST FRIENDS +document.querySelector('#main-content .container').innerHTML = ` + + +
+ + + +
+ + +
+ + + +
+` + +const ClearPins = document.getElementById('clear-pins') +const ClearBF = document.getElementById('clear-bf') +const EditSettingName = document.getElementById('edit-setting-name') +const EditSettingValue = document.getElementById('edit-setting-value') +const EditSettingBtn = document.getElementById('edit-setting') + +ClearPins.addEventListener('click', function(){ + chrome.storage.sync.set({ 'PolyPlus_PinnedGames': [] }, function() { + alert('Successfully cleared Pinned Games.') + }); +}); + +ClearBF.addEventListener('click', function(){ + chrome.storage.sync.set({ 'PolyPlus_BestFriends': [] }, function() { + alert('Successfully cleared Best Friends.') + }); +}); + +EditSettingBtn.addEventListener('click', function(){ + chrome.storage.sync.get(['PolyPlus_Settings'], function(result) { + result = result.PolyPlus_Settings + + let NewValue = EditSettingValue.value + if (NewValue === "true") {NewValue = true} + if (NewValue === "false") {NewValue = false} + if (parseInt(NewValue)) {NewValue = parseInt(NewValue)} + result[EditSettingName.value] = NewValue + + chrome.storage.sync.set({ 'PolyPlus_Settings': result }, function() { + alert('Successfully set: "' + EditSettingName.value + '" to ' + NewValue) + }); + + alert('Successfully cleared Best Friends.') + }); +}); \ No newline at end of file diff --git a/js/forum/forum-view-old.js b/js/forum/forum-view-old.js new file mode 100755 index 0000000..f999098 --- /dev/null +++ b/js/forum/forum-view-old.js @@ -0,0 +1,173 @@ +var idCache = [] +let url = "https://polytoria.com/users/:id" + +console.log('loaded!') + +function LowAttentionSpanMode() { + let PostContent = document.querySelector('.mcard p:nth-child(3)').textContent + let Captions = CombineArray(PostContent.split(' ')).map((x, i) => `${x}`).join('') + let NumberOfCaptions = (PostContent.split(' ').length) - 1 + Swal.fire({ + title: "No Attention Span Mode", + html: ` +