Skip to content

Instantly share code, notes, and snippets.

@ozh
Last active December 16, 2015 20:50
Show Gist options
  • Select an option

  • Save ozh/5495656 to your computer and use it in GitHub Desktop.

Select an option

Save ozh/5495656 to your computer and use it in GitHub Desktop.

Revisions

  1. ozh revised this gist Dec 28, 2013. 2 changed files with 28 additions and 0 deletions.
    28 changes: 28 additions & 0 deletions gistfile7.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    // Share on Tumlr

    var d = document,
    w = window,
    enc = encodeURIComponent,
    share = 'tumblr',
    e = w.getSelection,
    k = d.getSelection,
    x = d.selection,
    s = (e ? e() : (k) ? k() : (x ? x.createRange().text : 0)),
    s2 = ((s.toString() == '') ? s : '%20%22' + enc(s) + '%22'),
    f = 'http://sho.rt/admin/index.php',
    l = d.location.href,
    ups = l.match( /^[a-zA-Z0-9\+\.-]+:(\/\/)?/ )[0],
    ur = l.split(new RegExp(ups))[1],
    ups = ups.split(/\:/),
    p = '?up=' + enc(ups[0]+':') + '&us=' + enc(ups[1]) + '&ur='+enc(ur) + '&t=' + enc(d.title) + '&s=' + s2 + '&share=' + share,
    u = f + p;
    try {
    throw ('ozhismygod');
    } catch (z) {
    a = function () {
    if (!w.open(u,'Share','width=450,height=450,left=430','_blank')) l = u;
    };
    if (/Firefox/.test(navigator.userAgent)) setTimeout(a, 0);
    else a();
    }
    void(0);
    File renamed without changes.
  2. ozh revised this gist Dec 28, 2013. 2 changed files with 11 additions and 5 deletions.
    7 changes: 5 additions & 2 deletions gistfile1.js
    Original file line number Diff line number Diff line change
    @@ -4,8 +4,11 @@ var d = document,
    enc = encodeURIComponent,
    share = 'facebook',
    f = 'http://sho.rt/admin/index.php',
    l = d.location,
    p = '?u=' + enc(l.href) + '&t=' + enc(d.title) + '&share=' + share,
    l=d.location.href,
    ups=l.match( /^[a-zA-Z0-9\+\.-]+:(\/\/)?/ )[0];
    var ur=l.split(new RegExp(ups))[1];
    var ups=ups.split(/\:/);
    p = '?up=' + enc(ups[0]+':') + '&us=' + enc(ups[1]) + '&ur=' + enc(ur) + '&t=' + enc(d.title) + '&share=' + share,
    u = f + p;
    try {
    throw ('ozhismygod');
    9 changes: 6 additions & 3 deletions gistfile2.js
    Original file line number Diff line number Diff line change
    @@ -10,14 +10,17 @@ var d = document,
    s = (e ? e() : (k) ? k() : (x ? x.createRange().text : 0)),
    s2 = ((s.toString() == '') ? s : '%20%22' + enc(s) + '%22'),
    f = 'http://sho.rt/admin/index.php',
    l = d.location,
    p = '?u=' + enc(l.href) + '&t=' + enc(d.title) + s2 + '&share=' + share,
    l = d.location.href,
    ups = l.match( /^[a-zA-Z0-9\+\.-]+:(\/\/)?/ )[0],
    ur = l.split(new RegExp(ups))[1],
    ups = ups.split(/\:/),
    p = '?up=' + enc(ups[0]+':') + '&us=' + enc(ups[1]) + '&ur='+enc(ur) + '&t=' + enc(d.title) + s2 + '&share=' + share,
    u = f + p;
    try {
    throw ('ozhismygod');
    } catch (z) {
    a = function () {
    if (!w.open(u,'Share','width=780,height=265,left=100','_blank')) l.href = u;
    if (!w.open(u,'Share','width=780,height=265,left=100','_blank')) l = u;
    };
    if (/Firefox/.test(navigator.userAgent)) setTimeout(a, 0);
    else a();
  3. ozh revised this gist Dec 28, 2013. 1 changed file with 12 additions and 12 deletions.
    24 changes: 12 additions & 12 deletions gistfile6.js
    Original file line number Diff line number Diff line change
    @@ -1,22 +1,22 @@
    // Custom Popup (prompt for a keyword + on-page popup)

    var d = document,
    l = d.location.href,
    k = prompt('Custom URL'),
    l = d.location.href,
    k = prompt('Custom URL'),
    enc = encodeURIComponent,
    ups = l.match( /^[a-zA-Z0-9\+\.-]+:(\/\/)?/ )[0],
    ur = l.split(new RegExp(ups))[1],
    ups = ups.split(/\:/),
    p = '?up='+enc(ups[0]+':')+'&us='+enc(ups[1])+'&ur='+enc(ur)+'&t='+enc(d.title);
    sc = d.createElement('script');
    sc = d.createElement('script');
    if (k != null) {
    window.yourls_callback = function (r) {
    if (r.short_url) {
    prompt(r.message, r.short_url);
    } else {
    alert('An error occured: ' + r.message);
    }
    };
    sc.src = 'http://sho.rt/admin/index.php' + p + '&k=' + k + '&jsonp=yourls';
    void(d.body.appendChild(sc));
    window.yourls_callback = function (r) {
    if (r.short_url) {
    prompt(r.message, r.short_url);
    } else {
    alert('An error occured: ' + r.message);
    }
    };
    sc.src = 'http://sho.rt/admin/index.php' + p + '&k=' + k + '&jsonp=yourls';
    void(d.body.appendChild(sc));
    }
  4. ozh revised this gist Dec 28, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile7.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    Tips:

    - http://streetpc.instanceof.me/text-utilities/ to unescape a bookmarklet
    - http://ozh.org/text/ various text utilities, for instance to unescape a bookmarklet
    - http://jsbeautifier.org/ to prettify and make readable
    - http://ted.mielczarek.org/code/mozilla/bookmarklet.html to crunch back into a bookmarklet
  5. ozh revised this gist Dec 28, 2013. 7 changed files with 101 additions and 2 deletions.
    2 changes: 1 addition & 1 deletion gistfile1.js
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,7 @@
    var d = document,
    enc = encodeURIComponent,
    share = 'facebook',
    f = '<?php echo yourls_admin_url("index.php"); ?>',
    f = 'http://sho.rt/admin/index.php',
    l = d.location,
    p = '?u=' + enc(l.href) + '&t=' + enc(d.title) + '&share=' + share,
    u = f + p;
    2 changes: 1 addition & 1 deletion gistfile2.js
    Original file line number Diff line number Diff line change
    @@ -9,7 +9,7 @@ var d = document,
    x = d.selection,
    s = (e ? e() : (k) ? k() : (x ? x.createRange().text : 0)),
    s2 = ((s.toString() == '') ? s : '%20%22' + enc(s) + '%22'),
    f = '<?php echo yourls_admin_url("index.php"); ?>',
    f = 'http://sho.rt/admin/index.php',
    l = d.location,
    p = '?u=' + enc(l.href) + '&t=' + enc(d.title) + s2 + '&share=' + share,
    u = f + p;
    27 changes: 27 additions & 0 deletions gistfile3.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    // Simple Standard (new page)

    var d = document,
    w = window,
    enc = encodeURIComponent,
    e = w.getSelection,
    k = d.getSelection,
    x = d.selection,
    s = (e ? e() : (k) ? k() : (x ? x.createRange().text : 0)),
    s2 = ((s.toString() == '') ? s : enc(s)),
    f = 'http://sho.rt/admin/index.php',
    l = d.location.href,
    ups = l.match( /^[a-zA-Z0-9\+\.-]+:(\/\/)?/ )[0],
    ur = l.split(new RegExp(ups))[1],
    ups = ups.split(/\:/),
    p = '?up='+enc(ups[0]+':')+'&us='+enc(ups[1])+'&ur='+enc(ur)+'&t='+enc(d.title)+'&s='+s2,
    u = f + p;
    try {
    throw ('ozhismygod');
    } catch (z) {
    a = function () {
    if (!w.open(u)) l.href = u;
    };
    if (/Firefox/.test(navigator.userAgent)) setTimeout(a, 0);
    else a();
    }
    void(0);
    20 changes: 20 additions & 0 deletions gistfile4.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    // Simple Popup (in-page popup dialog)

    var d = document,
    w = window,
    sc = d.createElement('script'),
    l = d.location.href,
    enc = encodeURIComponent,
    ups = l.match( /^[a-zA-Z0-9\+\.-]+:(\/\/)?/ )[0],
    ur = l.split(new RegExp(ups))[1],
    ups = ups.split(/\:/),
    p = '?up='+enc(ups[0]+':')+'&us='+enc(ups[1])+'&ur='+enc(ur)+'&t='+enc(d.title);
    w.yourls_callback = function (r) {
    if (r.short_url) {
    prompt(r.message, r.short_url);
    } else {
    alert('An error occured: ' + r.message);
    }
    };
    sc.src = 'http://sho.rt/admin/index.php' + p + '&jsonp=yourls';
    void(d.body.appendChild(sc));
    30 changes: 30 additions & 0 deletions gistfile5.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    // Custom Standard (prompt for a keyword)

    var d = document,
    enc = encodeURIComponent,
    e = window.getSelection,
    k = d.getSelection,
    x = d.selection,
    s = (e ? e() : (k) ? k() : (x ? x.createRange().text : 0)),
    s2 = ((s.toString() == '') ? s : enc(s)),
    f = 'http://sho.rt/admin/index.php',
    l = d.location.href,
    ups = l.match( /^[a-zA-Z0-9\+\.-]+:(\/\/)?/ )[0],
    ur = l.split(new RegExp(ups))[1],
    ups = ups.split(/\:/),
    k = prompt("Custom URL"),
    k2 = (k ? '&k=' + k : ""),
    p = '?up='+enc(ups[0]+':')+'&us='+enc(ups[1])+'&ur='+enc(ur)+'&t='+enc(d.title)+'&s='+s2 + k2,
    u = f + p;
    if (k != null) {
    try {
    throw ('ozhismygod');
    } catch (z) {
    a = function () {
    if (!w.open(u)) l = u;
    };
    if (/Firefox/.test(navigator.userAgent)) setTimeout(a, 0);
    else a();
    }
    void(0)
    }
    22 changes: 22 additions & 0 deletions gistfile6.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    // Custom Popup (prompt for a keyword + on-page popup)

    var d = document,
    l = d.location.href,
    k = prompt('Custom URL'),
    enc = encodeURIComponent,
    ups = l.match( /^[a-zA-Z0-9\+\.-]+:(\/\/)?/ )[0],
    ur = l.split(new RegExp(ups))[1],
    ups = ups.split(/\:/),
    p = '?up='+enc(ups[0]+':')+'&us='+enc(ups[1])+'&ur='+enc(ur)+'&t='+enc(d.title);
    sc = d.createElement('script');
    if (k != null) {
    window.yourls_callback = function (r) {
    if (r.short_url) {
    prompt(r.message, r.short_url);
    } else {
    alert('An error occured: ' + r.message);
    }
    };
    sc.src = 'http://sho.rt/admin/index.php' + p + '&k=' + k + '&jsonp=yourls';
    void(d.body.appendChild(sc));
    }
    File renamed without changes.
  6. ozh created this gist May 1, 2013.
    19 changes: 19 additions & 0 deletions gistfile1.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    // Share on Facebook

    var d = document,
    enc = encodeURIComponent,
    share = 'facebook',
    f = '<?php echo yourls_admin_url("index.php"); ?>',
    l = d.location,
    p = '?u=' + enc(l.href) + '&t=' + enc(d.title) + '&share=' + share,
    u = f + p;
    try {
    throw ('ozhismygod');
    } catch (z) {
    a = function () {
    if (!window.open(u,'Share','width=500,height=340,left=100','_blank')) l.href = u;
    };
    if (/Firefox/.test(navigator.userAgent)) setTimeout(a, 0);
    else a();
    }
    void(0);
    25 changes: 25 additions & 0 deletions gistfile2.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    // Share on Twitter

    var d = document,
    w = window,
    enc = encodeURIComponent,
    share = 'twitter',
    e = w.getSelection,
    k = d.getSelection,
    x = d.selection,
    s = (e ? e() : (k) ? k() : (x ? x.createRange().text : 0)),
    s2 = ((s.toString() == '') ? s : '%20%22' + enc(s) + '%22'),
    f = '<?php echo yourls_admin_url("index.php"); ?>',
    l = d.location,
    p = '?u=' + enc(l.href) + '&t=' + enc(d.title) + s2 + '&share=' + share,
    u = f + p;
    try {
    throw ('ozhismygod');
    } catch (z) {
    a = function () {
    if (!w.open(u,'Share','width=780,height=265,left=100','_blank')) l.href = u;
    };
    if (/Firefox/.test(navigator.userAgent)) setTimeout(a, 0);
    else a();
    }
    void(0);
    5 changes: 5 additions & 0 deletions gistfile3.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    Tips:

    - http://streetpc.instanceof.me/text-utilities/ to unescape a bookmarklet
    - http://jsbeautifier.org/ to prettify and make readable
    - http://ted.mielczarek.org/code/mozilla/bookmarklet.html to crunch back into a bookmarklet