Tiny Core Extensions > TCE Tips & Tricks

Extentions Repository Browser Userscript

(1/1)

teh-botol:
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: ---// ==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;
    });
})();

--- End code ---


BR,
adit

Misalf:
Hi teh-botol,
pretty cool!
works with Greasemonkey in Firefox, too.
Thanks.

mocore:
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

Navigation

[0] Message Index

Go to full version