WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Extentions Repository Browser Userscript  (Read 6555 times)

Offline teh-botol

  • Newbie
  • *
  • Posts: 23
Extentions Repository Browser Userscript
« on: January 16, 2017, 09:05:19 AM »
Hi Guys,

I just want to share a script to browse extensions repository without a hassle.

Background:
I use TinyCoreLinux to make an appliance.
Mostly working with emulator and or ssh + X11 forwarding.
The annoying part is browsing the extension's description, list and dependencies.

Tested with Chrome and extension Tampermonkey (http://tampermonkey.net/).
Basically, the Tampermonkey will run the script at specific url with jQuery injected.
But the script itself can be used to any modern browser with other userscript manager.


Here goes:
Code: [Select]
// ==UserScript==
// @name         TinyCore Repository
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Less hassle browsing extentions.
// @author       adit.bisa@gmail.com
// @match        http://tinycorelinux.net/*/tcz/
// @grant        none
// @require      https://code.jquery.com/jquery-2.1.4.min.js
// ==/UserScript==

(function() {
    'use strict';

    var list = $('body').text().split('\n');
    $('body').html(
        '<style>' +
        ' body, input { font: 12px courier; } ' +
        ' a:hover { text-decoration: underline; } ' +
        ' .tcz > a { display: none; text-decoration: none; }' +
        ' .tcz:hover > a { display: inline-block; }' +
        ' #preview { position: fixed; top: 10px; right: 10px; }' +
        ' #url { width: 700px; }' +
        ' #browse { width: 678px; border: 1px solid #aaa; padding: 10px; height: 500px; overflow: auto; white-space: pre; }' +
        ' .error { color: red; }' +
        '</style>' +
        '<div id="preview">' +
        '  <input id="url" type="text">' +
        '  <br>' +
        '  <div id="browse">&nbsp;</div>' +
        '</div>'
    );
   
    for (var i=0; i<list.length; i++) {
        var fname = list[i];
        var tcz = $('<div class="tcz">').appendTo('body');
        tcz.data('fname', fname);
        tcz.append('<span class="fname">' + fname + '</span>');
        tcz.append(' <a href="#' + fname + '.info" class="info">[info]</a>');
        tcz.append(' <a href="#' + fname + '.list" class="list">[list]</a>');
        tcz.append(' <a href="#' + fname + '.dep" class="dep">[dep]</a>');
    }
   
    $('a').click(function(event){
        event.preventDefault();
        var a = $(this);
        var url = document.location + a.attr('href').substr(1);
        $.ajax({
            url: url,
            success: function(data){
                $('#url').val(url);
                $('#browse').html(data);
            },
            error: function(){
                $('#url').val(url);
                $('#browse').html('<span class="error">Error!</span>');
            }
        });
        return false;
    });
})();


BR,
adit

Offline Misalf

  • Hero Member
  • *****
  • Posts: 1702
Re: Extentions Repository Browser Userscript
« Reply #1 on: January 16, 2017, 10:11:02 AM »
Hi teh-botol,
pretty cool!
works with Greasemonkey in Firefox, too.
Thanks.
Download a copy and keep it handy: Core book ;)

Offline mocore

  • Hero Member
  • *****
  • Posts: 633
  • ~.~
Re: Extentions Repository Browser Userscript
« Reply #2 on: September 30, 2019, 05:06:52 AM »
thanks teh-botol for this simple and succinct script

ftr

i just posted a slightly modifyed of this version that should run from ( socat+bash scriped) local server
@ http://forum.tinycorelinux.net/index.php/topic,22843.msg145412.html#msg145412
« Last Edit: September 30, 2019, 05:08:28 AM by mocore »