Categories > Coding > Javascript >

View Scripts As A List!

Posts: 94

Threads: 14

Joined: Nov, 2018

Reputation: 8

Posted

A simple scripts which transforms your scripts page into a list!

 

1. Why Should I Use This?

  • Yes.

2. Screenshots

https://anopic.us/I3U0SPVPApVyIoZp0OKyixftMJ0wNLsNqTKxVnVx.jpg

3. Source-Code (use via TamperMonkey or you can copy-paste into the console directly everytime)

// ==UserScript==
// @Name         DLCardsToList
// @namespace    http://tampermonkey.net/
// @Version      0.1
// @description  Just for fun.
// @author       SoundInfinity
// @match        https://wearedevs.net/scripts
// @Icon         https://www.google.com/s2/favicons?domain=wearedevs.net
// @Grant        none
// ==/UserScript==

(function () {
    'use strict';

    //#region JSONTOTABLE LIB
    function ConvertJsonToTable(parsedJson, tableId, tableClassName, linkText) { var italic = "<i>{0}</i>", link = linkText ? '<a href="{0}">' + linkText + "</a>" : '<a href="{0}">{0}</a>', idMarkup = tableId ? ' id="' + tableId + '"' : "", classMarkup = tableClassName ? ' class="' + tableClassName + '"' : "", tbl = '<table border="1" cellpadding="1" cellspacing="1"' + idMarkup + classMarkup + ">{0}{1}</table>", th = "<thead>{0}</thead>", tb = "<tbody>{0}</tbody>", tr = "<tr>{0}</tr>", thRow = "<th>{0}</th>", tdRow = "<td>{0}</td>", thCon = "", tbCon = "", trCon = ""; if (parsedJson) { var isStringArray = "string" == typeof parsedJson[0], headers; if (isStringArray) thCon += thRow.format("value"); else if ("object" == typeof parsedJson[0]) { headers = array_keys(parsedJson[0]); for (var i = 0; i < headers.length; i++)thCon += thRow.format(headers[i]) } if (th = th.format(tr.format(thCon)), isStringArray) for (var i = 0; i < parsedJson.length; i++)tbCon += tdRow.format(parsedJson[i]), trCon += tr.format(tbCon), tbCon = ""; else if (headers) for (var urlRegExp = new RegExp(/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gi), javascriptRegExp = new RegExp(/(^javascript:[\s\S]*;$)/gi), i = 0; i < parsedJson.length; i++) { for (var j = 0; j < headers.length; j++) { var value = parsedJson[i][headers[j]], isUrl = urlRegExp.test(value) || javascriptRegExp.test(value); tbCon += isUrl ? tdRow.format(link.format(value)) : value ? "object" == typeof value ? tdRow.format(ConvertJsonToTable(eval(value.data), value.tableId, value.tableClassName, value.linkText)) : tdRow.format(value) : tdRow.format(italic.format(value).toUpperCase()) } trCon += tr.format(tbCon), tbCon = "" } return tb = tb.format(trCon), tbl = tbl.format(th, tb), tbl } return null } function array_keys(t, a, e) { var r = void 0 !== a, o = [], n = !!e, l = !0, s = ""; if (t && "object" == typeof t && t.change_key_case) return t.keys(a, e); for (s in t) t.hasOwnProperty(s) && (l = !0, r && (n && t[s] !== a ? l = !1 : t[s] != a && (l = !1)), l && (o[o.length] = s)); return o } String.prototype.format = function () { var t = arguments; return this.replace(/{(\d+)}/g, function (a, e) { return void 0 !== t[e] ? t[e] : "{" + e + "}" }) };
    //#endregion

    function releases_get() {
        const collection = []
        for (let release of document.querySelectorAll('.release-card')) {
            const title = release.querySelector('.release-title').textContent
            const description = release.querySelector('.release-description > p').textContent
            const author = release.querySelector('p').textContent
            collection.push({
                Title: `<a href=" ${release.querySelector('.download-button').getAttribute('href')} ">${title}</a>`,
                Description: description,
                Author: author
            })
        }
        return collection
    }

    function resources_init() {
        const sheet = document.createElement('style')
        sheet.innerHTML = `@import url(https://wearedevs.net/css/main.css);@import url(https://wearedevs.net/css/themes/night.css);table{margin:auto;padding:2vh 3vw}td {height:2.5vh;font-size:14px;padding-right:2vw}tr:nth-child(even) {background-color: #ffffff26;color:#eaeaea}a{text-decoration:underline;color:#eaedee}`
        document.head.appendChild(sheet)
    }

    document.querySelector('main').innerHTML = ConvertJsonToTable(releases_get())
    document.querySelector('table').className = 'theme1 round'

    resources_init()
})()

credits:

(library) Json to HTML Table :: https://github.com/afshinm/Json-to-HTML-Table

 

(made this for fun, so probably won't get any updates in the future)

  • 0

GitHub: https://github.com/sound-infinity

Discord: SoundInfinity#2135

Moon

Moon

vip

Posts: 7441

Threads: 314

Joined: Aug, 2020

Reputation: 80

Replied

An update to WRD+ when

  • 0

MINISHXP

[REDACTED]

Posts: 976

Threads: 3

Joined: Jan, 2021

Reputation: 9

Replied

can u explain what is the purpose of function() {}() ? i dont really do js but i dont see the point of doing the func thing

  • 0

Posts: 94

Threads: 14

Joined: Nov, 2018

Reputation: 8

Replied

@Moon Since the release of BWRD I haven't tought of putting more work into the script :p. But, I still have it as a side-project so eventually it might get an update

  • 0

GitHub: https://github.com/sound-infinity

Discord: SoundInfinity#2135

Moon

Moon

vip

Posts: 7441

Threads: 314

Joined: Aug, 2020

Reputation: 80

Replied

  • 0

Users viewing this thread:

( Members: 0, Guests: 1, Total: 1 )