From d7c72b0f96d3dbe8cc3d31bfde527fc346dc1aef Mon Sep 17 00:00:00 2001 From: flashwave Date: Thu, 29 Sep 2022 22:27:07 +0000 Subject: [PATCH] Tabs in whois --- public/assets/2021whois.js | 67 ++++++++++--------- public/assets/2022.css | 12 ++++ public/css/2021.css | 40 +++++++++++ public/userscripts/index.php | 59 ---------------- public/userscripts/nabucco-cleanup.user.css | 28 -------- .../userscripts/remove-trending-tab.user.js | 18 ----- public/userscripts/skip-youtube-home.user.js | 9 --- .../sock-emote-overflow-fix.user.css | 7 -- tpl/whois.php | 7 +- 9 files changed, 94 insertions(+), 153 deletions(-) create mode 100644 public/assets/2022.css delete mode 100644 public/userscripts/index.php delete mode 100644 public/userscripts/nabucco-cleanup.user.css delete mode 100644 public/userscripts/remove-trending-tab.user.js delete mode 100644 public/userscripts/skip-youtube-home.user.js delete mode 100644 public/userscripts/sock-emote-overflow-fix.user.css diff --git a/public/assets/2021whois.js b/public/assets/2021whois.js index 0429029..1f18499 100644 --- a/public/assets/2021whois.js +++ b/public/assets/2021whois.js @@ -2,7 +2,8 @@ var locked = false, input = document.getElementById('lookup-input'), submit = document.getElementById('lookup-submit'), - result = document.getElementById('lookup-result'); + result = document.getElementById('lookup-result'), + tabs = document.getElementById('lookup-tabs'); var lock = function() { if(locked) @@ -32,41 +33,45 @@ xhr.addEventListener('load', function() { var resp = JSON.parse(xhr.responseText); - if(resp.error) { + if(resp.error) alert(resp.text); - } else { - var lastWhois = resp.result.responses[resp.result.responses.length - 1], - isIpAddr = false; - for(var i = 0; i < lastWhois.lines.length; ++i) { - var line = lastWhois.lines[i]; - if(line.substring(0, 4) === 'inet') { - isIpAddr = true; - break; - } + tabs.innerHTML = ''; + if(resp.result && resp.result.responses) { + for(var i = 0; i < resp.result.responses.length; ++i) { + (function(response) { + var tab = document.createElement('a'), + tabHeader = document.createElement('div'), + tabServer = document.createElement('div'); + + tab.href = 'javascript:;'; + tab.className = 'whois-result-tab'; + if(i === 0) tab.className += ' whois-result-tab-active'; + + tab.onclick = function() { + var active = document.querySelector('.whois-result-tab-active'); + if(active) active.classList.remove('whois-result-tab-active'); + tab.classList.add('whois-result-tab-active'); + result.textContent = response.lines.join("\r\n").trim(); + }; + + tabHeader.className = 'whois-result-tab-header'; + tabHeader.textContent = i === 0 ? 'Result' : ('Hop #' + (resp.result.responses.length - i).toString()); + + tabServer.className = 'whois-result-tab-server'; + tabServer.textContent = response.server; + console.log(response); + + tab.appendChild(tabHeader); + tab.appendChild(tabServer); + tabs.appendChild(tab); + })(resp.result.responses[i]); } - - var text = ''; - - if(isIpAddr) { - text += 'RESULTS FOUND: ' + resp.result.responses.length.toString() + "\r\n"; - for(var i = 0; i < resp.result.responses.length; ++i) { - var response = resp.result.responses[i]; - text += "\r\n-------------\r\n"; - text += 'Lookup results for ' + resp.result.target + ' from ' + response.server + ":\r\n\r\n"; - text += response.lines.join("\r\n").trim() + "\r\n"; - } - } else { - for(var i = 0; i < resp.result.responses.length; ++i) { - var response = resp.result.responses[i]; - text += resp.result.target + ' domain lookup result from ' + response.server + "\r\n\r\n"; - text += response.lines.join("\r\n").trim() + "\r\n\r\n"; - } - } - - result.textContent = text; } + if(tabs.firstChild) + tabs.firstChild.click(); + unlock(); }); xhr.open('GET', '/whois/lookup?target=' + encodeURIComponent(target)); diff --git a/public/assets/2022.css b/public/assets/2022.css new file mode 100644 index 0000000..63d6744 --- /dev/null +++ b/public/assets/2022.css @@ -0,0 +1,12 @@ +* { + margin: 0; + padding: 0; + box-sizing: border-box; + position: relative; + outline-style: none; +} + +html, body { + width: 100%; + height: 100%; +} diff --git a/public/css/2021.css b/public/css/2021.css index 0e41c91..c695ee3 100644 --- a/public/css/2021.css +++ b/public/css/2021.css @@ -1182,3 +1182,43 @@ body { .whois-locked .whois-result { opacity: .5; } + +.whois-result-tabs { + display: flex; + margin: 0 5px; +} +.whois-locked .whois-result-tabs { + opacity: .5; +} +.whois-result-tab { + margin: 0 5px; + padding: 6px 10px; + font-size: 14px; + transition: opacity .2s; + background-color: #202020; + border-radius: 5px; + box-shadow: 0 1px 5px #222; + opacity: .5; + cursor: pointer; + display: block; + color: #fff; + text-decoration: none; +} +.whois-result-tab:hover, +.whois-result-tab:focus { + opacity: .7; +} +.whois-result-tab-active { + opacity: 1 !important; +} +.whois-result-tab-header { + font-size: 1.3em; + line-height: 1.2em; +} +.whois-result-tab-server { + font-size: .9em; + line-height: 1.2em; + color: #888; + white-space: pre-wrap; + font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; +} diff --git a/public/userscripts/index.php b/public/userscripts/index.php deleted file mode 100644 index 04e02ce..0000000 --- a/public/userscripts/index.php +++ /dev/null @@ -1,59 +0,0 @@ - 'remove-trending-tab.user.js', - 'name' => 'Remove the Youtube Trending Tab', - ], - [ - 'file' => 'skip-youtube-home.user.js', - 'name' => 'Skip the Youtube homepage and go straight to subscriptions', - ], - [ - 'file' => 'mpvfriend.user.js', - 'name' => 'Open youtube links in mpv', - ], -]; - -$userstyles = [ - [ - 'file' => 'sock-emote-overflow-fix.user.css', - 'name' => 'Fix emoticon overflow in sock chat client', - ], - [ - 'file' => 'nabucco-cleanup.user.css', - 'name' => 'Cleaner nabucco', - ], -]; -?> -

Scripts

-You'll need something like GreaseMonkey for this.
-'; - -foreach($userscripts as $us) { - echo << - {$us['name']} - -HTML; -} - -echo ''; -?> -

Styles

-You'll need something like Stylus for this.
-'; - -foreach($userstyles as $us) { - echo << - {$us['name']} - -HTML; -} - -echo ''; -?> -
i can't be bothered to style this page
diff --git a/public/userscripts/nabucco-cleanup.user.css b/public/userscripts/nabucco-cleanup.user.css deleted file mode 100644 index caaefb5..0000000 --- a/public/userscripts/nabucco-cleanup.user.css +++ /dev/null @@ -1,28 +0,0 @@ -body { - background-image: initial; -} - -#logo { - width: 100%; -} - -#logo img { - display: none; -} - -#logo a { - display: block; - margin: 15px auto 0; - width: 120px; - height: 120px; - background-image: url('https://flashii.net/user-assets.php?u=9&m=avatar'); - background-size: 120px; -} - -#center { - font-size: 0.1em; -} - -#err { - font-size: 10em; -} diff --git a/public/userscripts/remove-trending-tab.user.js b/public/userscripts/remove-trending-tab.user.js deleted file mode 100644 index 49be162..0000000 --- a/public/userscripts/remove-trending-tab.user.js +++ /dev/null @@ -1,18 +0,0 @@ -// ==UserScript== -// @name Remove Trending tab -// @version 7 -// @grant none -// @include https://www.youtube.com/* -// ==/UserScript== - -window.addEventListener('load', function() { - var checkInterval = setInterval(function() { - var buttons = Array.from(document.querySelectorAll('[href="/feed/explore"], [href="/feed/trending"], [href="/channel/UCqVDpXKLmKeBU_yyt_QkItQ"]')); - - if(buttons.length) { - while(buttons.length) - buttons.pop().parentElement.remove(); - clearInterval(checkInterval); - } - }, 100); -}); diff --git a/public/userscripts/skip-youtube-home.user.js b/public/userscripts/skip-youtube-home.user.js deleted file mode 100644 index bab56e2..0000000 --- a/public/userscripts/skip-youtube-home.user.js +++ /dev/null @@ -1,9 +0,0 @@ -// ==UserScript== -// @name Skip YouTube home. -// @version 9001 -// @grant none -// @include https://www.youtube.com/ -// @run-at document-start -// ==/UserScript== - -location.assign('/feed/subscriptions'); diff --git a/public/userscripts/sock-emote-overflow-fix.user.css b/public/userscripts/sock-emote-overflow-fix.user.css deleted file mode 100644 index 4b82442..0000000 --- a/public/userscripts/sock-emote-overflow-fix.user.css +++ /dev/null @@ -1,7 +0,0 @@ -#emotes { - max-height: 30px; - max-width: 600px; - overflow: auto; - background-color: #212121; - border: 1px solid #808080; -} diff --git a/tpl/whois.php b/tpl/whois.php index 928f0d5..66c09a4 100644 --- a/tpl/whois.php +++ b/tpl/whois.php @@ -15,7 +15,12 @@ $self->block('container', function($self) { -
+
+
+
+ +
+