24

Update:

This script was previously called "Insert APT Link" but has now been renamed. As such, you need to uninstall any previous versions before installing the new one.

Screenshot / Code Snippet

About

This UserScript adds some buttons to the editing toolbar that allow the following to easily be inserted:

  • Package installation button:

    Software center

  • Package installation text and icon:

    stackapplet Install stackapplet

This UserScript is fully compatible with inline editing and the toolbar buttons should show up anywhere there is a WMD editor.

License

MIT License

Download

You can install the script by clicking the link below:
https://files.quickmediasolutions.com/userscripts/au_toolbar.user.js

Platform

Tested on Firefox 11 (and reported to work on Chrome too).

Contact

I can be reached at [email protected]

Code

Written in JavaScript using jQuery.

16
  • Can this be made into an addon? Greasemonkey doesn't work with nightlies :/
    – RolandiXor
    Jul 7, 2011 at 20:23
  • @Roland: Really? (Shame on GreaseMonkey!) Actually, I'm afraid I have never written a Firefox addon. Ever. :( Jul 7, 2011 at 20:25
  • I guess this is time for me to brush up on javascript and write a jetpack :).
    – RolandiXor
    Jul 7, 2011 at 22:26
  • Guess who got greasemonkey working since the latest update :D...
    – RolandiXor
    Jul 28, 2011 at 4:54
  • @Roland: Hooray! So what Firefox version are we working with now? :) Jul 28, 2011 at 4:56
  • Firefox 8 still, 9 is on the way but hasn't landed yet :)
    – RolandiXor
    Jul 28, 2011 at 5:20
  • Can this be updated to insert this new awesome button? meta.askubuntu.com/a/395/235 Apr 24, 2012 at 22:32
  • @JorgeCastro: Sure - that button looks awesome. Apr 25, 2012 at 5:56
  • It looks like apps.ubuntu.com is the preferred way to install now, see here: meta.askubuntu.com/a/395/235 Apr 25, 2012 at 16:20
  • This script is awesome! I took it and misused it to support some long wanted functionality on mathematica.SE. Nathan, I left your name as developer, your company URL and the download link for livequery.js in there. Would you mind leaving me a comment under our meta post whether this is OK or what I should change? Thanks.
    – halirutan
    Jul 6, 2013 at 14:32
  • @halirutan: I don't have an account on Mathematica.SE, but you are more than welcome to use my code and link to my hosted version of Livequery. I'm glad you were able to adapt my code so easily :) Jul 6, 2013 at 21:19
  • @NathanOsman Yes, it's tested now by several users and works like a charm. I was having a chat with Tim Stone yesterday about how I could have possibly found things like StackExchange.MarkdownEditor.refreshAllPreviews() because they are documented nowhere. That's why I'm so glad you did the hard work and I only had to use it.
    – halirutan
    Jul 6, 2013 at 21:23
  • @halirutan: Right - I spent a long time playing around with the Chrome Inspector before I figured that one out. Eventually I'm thinking of creating a JavaScript library with a bunch of functions for doing common things on Stack Exchange pages - like creating toolbar buttons, inserting text into the editor, and creating popup boxes. Then UserScripts can just include the library. Jul 6, 2013 at 22:52
  • @NathanOsman We found an issue: When you are not logged on SE or if you are a new user, than the markdown editor gets an additional toolbar which makes that your additional buttons are placed at the very left and are not visible completely.
    – halirutan
    Jul 8, 2013 at 13:49
  • Please see this screenshot. The most left Key button is the last of the three buttons I'm using. The reason for this shift to the left seems to be the additional Links Images ... toolbar which appears for guests or new users.
    – halirutan
    Jul 8, 2013 at 13:54

1 Answer 1

9

I've made some improvements:

  • [bugfix] At some pages, the button would not be added: Tag wiki and pressing "Add another answer"
  • [feature] selected text will now immediately be converted to an APT link
  • [feature] URLs like http://packages.ubuntu.com/package will now be converted to package (technically, it takes the part after the last /)
  • Code cleanup: stripping http:// made no sense and was possibly a leftover from copying code directly

Download:

Changelog:

  • 1.0.0.2 (13 June 2011): Release
  • 1.0.0.3 (7 July 2011): [bugfix] the editors textareas for posts seems to have a numeric ID part now.
  • 1.0.0.4 (7 July 2011): [bugfix] Edit Posts works now properly again
  • 1.0.0.5 (18 January 2015): [bugfix] Apply to https://askubuntu.com/ too, fix API usage, jshint fixes, use new artwork and app URL.
5
  • Thanks! Do you mind if I credit you and update the original? Jun 13, 2011 at 16:55
  • 1
    @GeorgeEdison: No problem, you may remove the download link from my answer after updating, keeping multiple (out-dated) copies is not a good idea. Could you add an link to this page in the userscript for future reference? E.g. @website http://stackapps.com/q/2405
    – Lekensteyn
    Jun 13, 2011 at 18:22
  • Chrome is giving me errors when I try to use the button when editing answers: Uncaught SyntaxError: Unexpected token ILLEGAL edit:13 // Uncaught TypeError: Object [object Object] has no method 'selection' Jun 15, 2011 at 6:44
  • I found the issue: I wrongly assumed that the selection method was something from jQuery (it's part of cdn.sstatic.net/Js/tageditor.js). I've also found an issue at the tag editing page which is now fixed. The download link has not changed, do not forget to clear your cache.
    – Lekensteyn
    Jun 15, 2011 at 8:22
  • Did a quick fix for the old Insert Apt Link userscript.
    – Lekensteyn
    Jan 18, 2015 at 21:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .