Tinify - a tiny script to make urls tiny

I wrote a small script to make urls tiny quickly. dependencies are curl and xclip (for convenience)
there are two possible ways to use this:
1. copy an url to the X clipboard, run the script (e.g. through a hotkey) and immediately paste the tinyurl again.
2. pass an URL as the first and only argument and tadaa, there is the tinified url on STDOUT (and also in the clipboard)
#!/bin/sh
# title: tinify
# author: Philip Stark
# desc: pass an url as the first and only argument to make it tiny or
# leave it away and it takes the content of the clipboard by
# calling xclip.
# licenced under the WTFPL (http://sam.zoy.org/wtfpl/)
if [ "$1" = "" ]; then
tinyurl=$(curl http://tinyurl.com/api-create.php?url=$(xclip -selection clipboard -o) 2> /dev/null)
echo $tinyurl;
echo $tinyurl | xclip -selection clipboard -i;
else
url=$1;
tinyurl=$(curl http://tinyurl.com/api-create.php?url=${url} 2> /dev/null)
echo $tinyurl;
echo $tinyurl | xclip -selection clipboard -i;
fi
version without xclip dependency (to keep it simple ):
#!/bin/sh
# title: tinify
# author: Philip Stark
# desc: pass an url as the first and only argument to make it tiny or
# leave it away and it takes the content of the clipboard by
# calling xclip.
# licenced under the WTFPL (http://sam.zoy.org/wtfpl/)
[ "$1" == "" ] && echo "Usage: tinify url" && exit
url=$1;
tinyurl=$(curl http://tinyurl.com/api-create.php?url=${url} 2> /dev/null)
echo $tinyurl;
have fun
cheers Barde
Last edited by Heller_Barde (2009-02-17 18:50:05)

i was actually kinda kidding about the licensing. it was very late and i was very tired so I decided i wanted to do a little bit of effort and make a real description and a license. it was even funnier considering the tinyness of the script
cheers Barde
Last edited by Heller_Barde (2009-02-17 18:35:14)

Similar Messages

  • Is possible to have a script that makes a text randomly have caps and lower caps... i would love to create a kind of effect so it would look like manuscript - but it cannot be only the same letter in caps or lower caps - I wOuld NeEd oF SOmeTHing LikE Thi

    Is possible to have a script that makes a text randomly have caps and lower caps... i would love to create a kind of effect so it would look like manuscript - but it cannot be only the same letter in caps or lower caps - I wOuld NeEd oF SOmeTHing LikE This (random) - is it possibel?

    Hi,
    Sample with 2 regex:
    Launching the 1rst regex:
    Launching the 2nd regex:

  • One script to make multiple cells call one function or vice versa

    Please help.
    I need one script to make multiple cells reference one function or one cell reference multiple functions.
    Goal: On the enter event of cell c1, I want to make cells (this, Header.c1, Example.c1, rLabel) highlighted, and this would be for every other cell that is entered into, their corresponding column header and row header will be highlighted.
    I've tried combining cells: eg
    colourControls.hdfieldLoseFocus(this, HeaderRow.c1, Example.c1, rLabel);
    and I've also tried combining some scripts in the function:
    fieldObj.ui.oneOfChild.border.fill.color.value = "255,255,200";
      HeaderRow.fieldObj.ui.oneOfChild.border.fill.color.value = "255,255,200";
      ExampleRow.fieldObj.ui.oneOfChild.border.fill.color.value = "255,255,200";
    But they dont work. See the link to my form.
    http://www.winstonanddavid.com/example.com
    I tried testing the function with the cell 'c1' but it doesnt work.
    Also, I want to get rid of the multiple lines of script in every other cell.
    How can I do this?

    I played around with the ExtendScript Toolkit and cutted and pasted the previous script from here until I managed to get a script that actually works like I was thinking. I then added a code from the CS4 Reference Manual to move Layer1 to the top (just to see if it worked).
    I have no idea yet if the the code includes something that does not belong, but at least I get no errors. The current code is like this now:
    //Apply to myDoc the active document
    var layerName = LayerOrderType;
    var myDoc = app.activeDocument;
    //define first character and how many layers do you need
    var layerName
    var numberOfLayers=0;
    //Create the layers
    for(var i=0; i<=numberOfLayers; i++)
    { var layerName = "Background";  var myLayer = myDoc.layers.add(); myLayer.name = layerName;  }
    { var layerName = "Picture";  var myLayer = myDoc.layers.add(); myLayer.name = layerName;  }
    { var layerName = "Text";  var myLayer = myDoc.layers.add(); myLayer.name = layerName;  }
    { var layerName = "Guides";  var myLayer = myDoc.layers.add(); myLayer.name = layerName;  }
    // Moves the bottom layer to become the topmost layer
    if (documents.length > 0) {
    countOfLayers = activeDocument.layers.length;
    if (countOfLayers > 1) {
    bottomLayer = activeDocument.layers[countOfLayers-1];
    bottomLayer.zOrder(ZOrderMethod.BRINGTOFRONT);
    else {
    alert("The active document only has only 1 layer")

  • Is there a script to make automatic footnotes?

    Yeasterday my boss gave me a book to lay out.
    I must do alphabetic index and over 1200 footnotes. If I imagine this proccess, it makes me sad
    The first part of this job isn't hard, because I plan to use two brilliant scripts to make index: IndexBrutal and IndexMatic.
    You can download  them from this website http://marcautret.free.fr
    But I need and plead for your help with footnotes. Is there a script to make automatic footnotes?
    Or, maybe, you know the faster way to do this boring repeating of mouse cliks?????
    Thanks a lot.

    Depends on what you mean by "make" footnotes. What are you making them from? I used a script from http://www.adobescripts.com/modules/mydownloads/viewcat.php?cid=9 once to convert thousands of endnotes back to into footnotes. And I'm sure there's a similar way to automate the process (either through scripting or a find/replace) if your footnotes are embedded in text but marked some way. For instance, if your footnotes look like this at the moment:
    text more text footnote number comes next (22) text of footnote here end of footnote comes next\ more text following footnote
    In this case, all footnote numbers show up between parentheses and all footnotes end with a backslash. If your footnotes are marked beginning and end in some similar fashion, then there's hope.
    Ken Benson

  • Need a script to make the browser fly over the screen, bouncing around

    I have heard about the youareanidiot.org virus. I need a script to make the browser fly over the screen, bouncing around. Do you have one?

    This is a professional forum, we do not help with jokes that will cost you your job.
    Don't retire TechNet! -
    (Don't give up yet - 13,225+ strong and growing)

  • How to make system update with "use automatic configuration script" and an URL

    Hello,
    all our laptop using "use automatic configuration script" with an "accelerated_pac_base.pac" prxy setting.
    How can we make system update work with that ?
    And no way for us to by pass this proxy settings with
    Thanks

    I mean there is no general method which is capable of correcting all possible errors found by schema validation.
    For example if the validation says it expected to find an <organization> element or a <company> element but it found a <banana> element, there is no way to determine what repair is necessary.
    Anyway the requirement is fighting against the way things work in the real world. The purpose of validation is just to find out whether a document matches a schema. If it doesn't, then too bad. Send it back to be fixed or replaced. If you are having a problem because you repeatedly get documents which don't quite match your schema, then you need to train the users to produce valid documents or to give them tools which help them do that.

  • Script to make 'delete' file from system and not just library svp.

    I would like something, possibly a script, to replace the delete option in iTunes so that a file deleted from within iTunes is actually deleted from the HDD. I have downloaded a script that can do this but the option ad to be called from the script menu and was not convenient, so I am looking for a way to amend or replace the menu option to achieve this in a natural fashion.

    Okay, here I found this page: http://ask.metafilter.com/18737/How-can-I-make-iTunes-delete-songs-again
    which is nice and informative. What I have found is that in order to delete files natively from within iTunes the default settings of keeping your music files in the iTunes music folder (which can be modified to another directory in iTune's preferences) must be left untouched. This is because iTunes will only delete files from the HDD if they reside in the music folder iTunes refences to. Its a nice structured system that iTunes itself keeps organised so its the better option, as oposed to having files everywhere.
    In order to reset the iTunes dialog messages, the file "com.apple.iTunes.plist" in the "~/Library/Preferences/" dir must be deleted - which resets everything, as the documentation suggests you will know because the copyright agreement will launch when iTunes is started. Please make sure iTunes is off before deleting the file. The documentation also suggests deleting another file but I didn't do this and it worked for me.
    However the ability to delete movies from the HDD is not an option from within iTunes, I suggest finding a script that will move all movies in a certain playlist to the recycle bin folder

  • I need to write a Java script to make my Art board bigger by 1 (one) inch on the Width and Length, Regardless of the Content?

    Hi,
    I am currently using "Visible bounds" (java script)to add 1 inch to the width and to the Length of my Art board, but when i make a clipping mask it actually reads the hidden content from the Clipping mask and makes conforms my art board to that particular shape. Am using Adobe illustrator cs6 Here is My Code:
    var myDocs = app.documents;
    var i = 0;
    for (i = myDocs.length-1 ; i >= 0; i--)
        var doc = myDocs[i];
        app.activeDocument= doc;
        var myVisibleBounds = doc.visibleBounds; //Rect, which is an array;
        myVisibleBounds[0] -= 36;
        myVisibleBounds[1] += 36;
        myVisibleBounds[2] += 36;
        myVisibleBounds[3] -= 36;
        doc.artboards[0].artboardRect = myVisibleBounds;
    All i Want is to add 1 inch to my width and length and this does it but if i have a clipping mask it will pick up the bounding box i guess? and it will conform it to the shape... any help please... Try my code and you will see that it does add 1 inch but now make you artboard lest say 12" x 12" and make a shape bigger than the art board and you will see how it adds 1 inch to the art board based on that shape...  now if you make a clipping mask to fit that shape in the 12" x 12" art board you will still get 1 inch bigger than the shape thats being clipped ... 

    yes, visible bounds is reading the non-visible masked objects too.
    you're going to have to do it the hard way, loop through all your objects to get your bounds manually, and while you're at it, test for clipping masks and use the masking path instead.

  • How to i write a script that makes multiple selections in a pdf and exports them to excel?

    I have a large number of PDFs
    Not all the PDFs contain information we need. We want to be able to automate a script that extracts certain info from the PDFs and opens them in a certain format in excel.
    Acrobat allows me to make a single selection and export as excel.
    How do i export multiple parts to excel from the pdfs and ensure that the resulting excel is in a format that i can use without much fixing needed (e.g. merged cells)?

    This type of process can't really be done using JavaScript. You would need to read the contents of the file, word by word, decide (based on some logic) what data to extract, and then collect it and at the end export to a plain-text file. Not a simple process...

  • How to make url portlet parameter permanent

    I have set up a url portlet inside portal.
    I put tags in the provider.xml file for an input parameter for my url portlet to use. (I used the <isMandatory>true</isMandatory> so I would be prompted inside portal for the value.)
    So, when I add the url portlet to a portal page a window pops up and asks me to submit a value for the portlet to use.
    The portlet runs sucessfully.
    MY QUESTION: How can I make the value that the page creator enters permanent so that the url portlet automatically picks it up whenever the page is run?
    My purpose is to be able to add this portlet to several different pages and have it use the value that was defined for it when the page was created.
    I have read several articles, but I must be missing something. Any ideas are appreciated.

    Hi,
    You can make the following change in your provider.xml file.
    <inputParameter class="oracle.portal.provider.v2.URLPortletParameter">
    <name>csz</name>
    <isMandatory>false</isMandatory>
    <value>Set your value here</value>
    <displayName>What location do you want a map for (City, State or Zip)?</displayName>
    </inputParameter>
    By doing so, it'll pick up the value from the provider.xml and append the value to the parameter in the URL, so that the constructed URL will have the parameter value without having to customize the page.
    I hope this answers your question. Do feel free to come back here if you have any more problems.
    Ashish.

  • Passing form field values, to an external script, in a URL

    We have a Dynamic, Reader Extended, Livecyce form from which we need to pass two user selected values to an external script. The values need to be passed via a URL, and cannot be static entries, but need to change based on user input.
    I have tried variations on the following example, without success.
    form1.page1.button::click - (JavaScript, client)
    var userselected1;
    userselected1 = form1.page1.field1.rawValue;
    var userselected2;
    userselected2 = form1.page1.field2.rawValue;
    xfa.host.gotoURL("http://ourdomain.com/script.php?selected1=userselected1&selected2=userselected2");
    Thanks,
    Ron

    Got it!! There is probably a more elegant method for achieving this, but the script below works for us. A new page opens in a browser, and displays information related to the variables passed to the script.
    form1.page1.button::click - (JavaScript, client)
    newURL1 = 'http://ourdomain.com.com/script.php?selected1=';
    newURL2 = userselected1;
    newURL3 = "&selected2=";
    newURL4 = userselected2;
    myNewURL = newURL1+newURL2+newURL3+newURL4;
    app.launchURL(myNewURL, true);
    Hope this helps someone else!!

  • A script to make all page references into hyperlinks

    Hi,
    I have a customer request to make all pages references into hyperlinks.
    For example: when you see in the text of the PDF "page 4", you can click on it and move to page 4. This of course can be done manually with InDesign. The problem starts when you have whole load of them. In addition to that, I have this project as a book, with several different documents...
    I used the script "Automatic hyperlink of each word in a file" from http://www.nobrainer.dk/automatic-hyperlink-of-each-word-in-a-file/ as a base, and modified it for my porpuse. Currently it still produces errors. Any idea what's the bug?
    if (app.documents.length > 0) {
    var myDocument = app.activeDocument;
    var myHyperlinkStyle = myDocument.characterStyles.item("hyperlink"); // replace hyperlink with name of your char style for links
    //alert(myHyperlinkStyle);
    main();
    } else {
    alert("Please open a document");
    function main() {
    app.findGrepPreferences = NothingEnum.nothing;
    app.changeGrepPreferences = NothingEnum.nothing;
    //the value to find
    myFindVal = "page (\\d+)";
    doSearchAndReplace(myFindVal, app.activeDocument);
    // reset search
    app.findGrepPreferences = NothingEnum.nothing;
    app.changeGrepPreferences = NothingEnum.nothing;
    function doSearchAndReplace(stringfind, searchin) {
    app.findGrepPreferences.findWhat = stringfind;
    //Set the find options.
    app.findChangeGrepOptions.includeFootnotes = true;
    app.findChangeGrepOptions.includeHiddenLayers = false;
    app.findChangeGrepOptions.includeLockedLayersForFind = false;
    app.findChangeGrepOptions.includeLockedStoriesForFind = false;
    app.findChangeGrepOptions.includeMasterPages = false;
    var myFoundItems = searchin.findGrep();
    for (i = 0; i < myFoundItems.length; i++) {
    var item = myFoundItems[i].contents;
    //the destination page
    var destPage = item.slice(5);
    var myHyperlinkDestination = myMakeHyperlinkDestination(destPage);
    myMakeHyperlink(myFoundItems[i], myHyperlinkDestination);
    myFoundItems[i].applyCharacterStyle(myHyperlinkStyle, false);
    function myMakeHyperlink(myFoundItem, myHyperlinkDestination){
    try {
    var myHyperlinkTextSource = myDocument.hyperlinkTextSources.add(myFoundItem);
    var myHyperlink = myDocument.hyperlinks.add(myHyperlinkTextSource, myHyperlinkDestination);
    myHyperlink.visible = false;
    catch(myError){
    function myMakeHyperlinkDestination(myDestPage){
    //If the hyperlink destination already exists, use it;
    //if it doesn't, then create it.
    try{
    var myHyperlinkDestination = myDocument.hyperlinkDestinations.item(myDestPage);
    myHyperlinkDestination.name;
    catch(myError){
    myHyperlinkDestination = myDocument.hyperlinkPageDestinations.add(myDestPage);
    myHyperlinkDestination.destinationPage = myDestPage;
    myHyperlinkDestination.name = myDestPage;
    //Set other hyperlink properties here, if necessary.
    return myHyperlinkDestination;

    well, after some more digging into it, I found the bugs and corrected, here is the corrected version (now I only need to figure out how to do it on an entire book...):
    if (app.documents.length > 0) {
    var myDocument = app.activeDocument;
    var myHyperlinkStyle = myDocument.characterStyles.item("hyperlink"); // replace hyperlink with name of your char style for links
    //alert(myHyperlinkStyle);
    main();
    } else {
    alert("Please open a document");
    function main() {
    app.findGrepPreferences = NothingEnum.nothing;
    app.changeGrepPreferences = NothingEnum.nothing;
    //the value to find
    myFindVal = "page (\\d+)";
    doSearchAndReplace(myFindVal, app.activeDocument);
    // reset search
    app.findGrepPreferences = NothingEnum.nothing;
    app.changeGrepPreferences = NothingEnum.nothing;
    function doSearchAndReplace(stringfind, searchin) {
    app.findGrepPreferences.findWhat = stringfind;
    //Set the find options.
    app.findChangeGrepOptions.includeFootnotes = true;
    app.findChangeGrepOptions.includeHiddenLayers = false;
    app.findChangeGrepOptions.includeLockedLayersForFind = false;
    app.findChangeGrepOptions.includeLockedStoriesForFind = false;
    app.findChangeGrepOptions.includeMasterPages = false;
    var myFoundItems = searchin.findGrep();
    for (i = 0; i < myFoundItems.length; i++) {
    var item = myFoundItems[i].contents;
    //the destination page
    var destPageNumber = item.slice(5);
    var destPage = searchin.pages.itemByName(destPageNumber);
    var myHyperlinkDestination = myMakeHyperlinkDestination(destPage);
    myMakeHyperlink(myFoundItems[i], myHyperlinkDestination);
    myFoundItems[i].applyCharacterStyle(myHyperlinkStyle, false);
    function myMakeHyperlink(myFoundItem, myHyperlinkDestination){
    try {
    var myHyperlinkTextSource = myDocument.hyperlinkTextSources.add(myFoundItem);
    var myHyperlink = myDocument.hyperlinks.add(myHyperlinkTextSource, myHyperlinkDestination);
    myHyperlink.visible = false;
    catch(myError){
    function myMakeHyperlinkDestination(myDestPage){
    //If the hyperlink destination already exists, use it;
    //if it doesn't, then create it.
    try{
    var myHyperlinkDestination = myDocument.hyperlinkDestinations.item(myDestPage);
    myHyperlinkDestination.name;
    catch(myError){
    myHyperlinkDestination = myDocument.hyperlinkPageDestinations.add(myDestPage);
    myHyperlinkDestination.destinationPage = myDestPage;
    //myHyperlinkDestination.name = myDestPage.name;
    //Set other hyperlink properties here, if necessary.
    return myHyperlinkDestination;

  • Make URL-like text a real URL in PDF file.

    Hi!
    I have a task to make all URL-like text (and e-mail-like text later) in a PDF file a real URLs. It's needed for the pdf2swf tool (SWFTools) to produce swf with clickable links.
    As i undestand Acrobat reader automatically converts such text into links, but the pdf2swf don't.

    Reader will only convert the links if the start with http://. Links that start with www won't be recognized. Also,
    that option can be turned off by the user so I wouldn't depend on them.
    You would need to use the link tool in Adobe Acrobat to create actual links.

  • Can I script the 'Make This My Card' option of AddressBook

    I would like to be able to select my card and then the 'Card-menu -> Make This My Card' menu-option from within a script, so that I can make sure 'My Card' is always properly defined.
    I have tried Automator and AppleScript, but so far I did not find a way to accomplish this.
    Anybody out ther that can help me?
    Kind regards,
    Adam.

    What problem are you having with the definition of your card?
    Anyway, play with this script and see if you can make it do what you want.
    AK
    click here to open this script in your editor<pre style="font-family: 'Monaco', 'Courier New', Courier, monospace; overflow:auto; color: #222; background: #DDD; padding: 0.2em; font-size: 10px; width:400px">tell application "Address Book"
    set stuff to the selection
    set my card to item 1 of stuff
    end tell</pre>

  • "Lorem ipsum"-izer script to make your documents make less sense

    I made some newspaper mock-ups and needed to change the text of existing pages into lorem-ipsum nonsense, while keeping the formatting and amount of text the same. So I made this scripts. It will change any words in the current selection into nonsense.
    It's a bit slow because it loops through every single word in the selection and changes it into latin-sounding words with the same number of characters, and then adds or subtracts some letters to make sure the text is pretty much the same number of lines in the end.
    I have only tested it with CS3.
    for (var n=0; n<app.selection.length; n++){
         loremIpsumize(app.selection[n]);
    function loremIpsumize(myText){ // myText could be a TextFrame, Story, InsertionPoint, Word, Text etc...
         var loremIpsumDictionary = [[""], // this is the dictionary of words sorted by number of letters. The words are taken from InDesigns "fill with placeholder text"-feature
                           ["a","e","y"],
                           ["el","si","em","se","an","er","do","re","te","at","os","od","to","et","eu","ud","na","ex","ed","ut","ad","il","in","la","it","is","ip","am","ea"],
                           ["ing","lam","vel","lan","lis","lor","ute","ver","con","lum","lut","ibh","del","unt","min","mod","feu","nim","nis","nit","non","nos","bla","eum","eui","num","aut","dio","odo","wis","tis","tio","pis","pit","qui","ate","tin","tie","ese","tet","tem","dip","rat","ero","ril","rit","ros","dit"],
                           ["duis","alit","dunt","ecte","sisi","elis","elit","enim","enis","enit","sent","wisl","erat","amet","tate","alis","erci","erit","wisi","eros","esed","esse","essi","dion","atem","atet","acil","esto","atio","quis","atue","etue","quip","ting","etum","atum","quat","quam","diat","euip","prat"],
                           ["lorem","ispum","magna","ulput","lutem","minci","minis","lummy","commy","adiat","minit","conse","lorer","lorem","ullum","adiam","lobor","modip","modit","lenit","lenim","laore","cipit","molor","utpat","velis","iusto","iusci","iurem","molum","velit","ullan","ullam","nisci"],
                           ["mconse","magnit","mincip","magnis","magnim","minisi","minisl","lutpat","wissis","wissim","acidui","modiat","commod","luptat","wiscip","wiscin","lumsan","wiscil","molent","cinibh","lortio","vulput","molore","lortin","lortie","vullut","vullan","vullam","ncidui","volute","lorper"],
                           ["feuisci","sustrud","ationse","feuisis","feuisit","feuguer","feuismo","feugiat","feummod","feugiam","hendiam","feugait","dolorem","andreet","suscipi","hendrem","hendrer","facipit","heniamc","amconul","atuerat","facipis","dolorer","facinim","tetummy","facinim","delesto"],
                           ["dolortis","vendreet","vullutat","consequi","niatuero","eugiamet","nismodit","adignibh","eugiatet","zzriusto","doluptat","veliquat","nonsecte","veliquam","velestis","dolortio","nonsenim","velessim","dolortin","dolortie","velenibh","nonsequi","veleniat","conullam","eraessit"],
                           ["iriliquis","blandipis","quismolor","irillamet","consequis","iriuscing","blaorerit","iriustrud","etuerosto","nissectet","vendiamet","volestisl","dionsenim","digniamet","eniatisit","quamcommy","iurerosto","ionsequat","ptatueros","consequat","duiscipit","scillummy","veliquisl"],
                           ["loremipsum","exeriurero","nummodolor","ullamcommy","veriliquat","conulputat","uismodolor","exeraessit","exerostrud","nullaortis","tisiscipis","nullaoreet","nullandrem","odigniamet","nullandiat","verciduisi","erciduisit","faciduisim","lummolessi","facincipit","voloreetum"],
                           ["dolortionum","veliquiscil","euguerostie","veliquamcon","aciliquisim","eummolestin","adionsequat","adipsustrud","vercincinis","dolorpercin","exeraestrud","ullaorperit","wismolobore","amconsequis","essequating","facipsustio","doloreetuer","elesequisim","augiametuer"],
                           ["dolutatueros","adigniamcore","velesequipit","adigniscipis","eummolortion","dolorperiure","dolorpercing","ulputpatetue","uipsuscidunt","aliquipsusci","tumsandionse","tionsequisim","facilismolut","facillametum","atueraestrud","sustionsenim","iliquatiniat","dolenismodit"]];
         var myStory; // the parent Story of myText
         if (myText instanceof Story){
              myStory = myText;
         } else if (myText instanceof InsertionPoint){
              myText = myStory = myText.parentStory;
         } else if (myText.hasOwnProperty("parentStory")){ // myText instanceof Word, TextFrame, Character, TextColumn or Paragraph
              myStory = myText.parentStory;
         } else { // myText is not text, but some other object
              return;
         if  (myText.hasOwnProperty("paragraphs") && !(myText instanceof Paragraph)){ // The script returns better looking results when one Paragraph is processed at a time
              var myParagraphs = myText.paragraphs.everyItem().getElements();
              for (var n=myParagraphs.length-1; n>=0 ; n--){
                   loremIpsumize(myParagraphs[n]); // clever recurson
         } else if (myText.contents!=""){
              app.findGrepPreferences = NothingEnum.nothing;
              app.changeGrepPreferences = NothingEnum.nothing;
              app.findGrepPreferences.findWhat = "[\\u\\l'@\u00E6\u00C6]{1,"+loremIpsumDictionary.length+"}"; // only looks for word-characters and leave punctuation, spaces as they are
              var storyLineNumber = myStory.lines.length; // remembers how many lines the story has, and tries to make the new text the same number of lines
              var myWordMatches = myText.findGrep(); // an array of Word references that fit the grep
              for (var i=myWordMatches.length-1; i>=0; i--){
                   myWordMatches[i].contents = loremipsumWord(myWordMatches[i].contents); // changes the word into a random latin-sounding one
              fineTuneText(storyLineNumber);
         function fineTuneText(targetNumberOfLines){ // tries to make the text the correct number of lines by adding or subtracting one letter at a time
              var myNumberOfCharacters;
              var newWord;
              var myWord;
              while (targetNumberOfLines != myStory.lines.length) {
                   myNumberOfCharacters = myText.characters.length;
                   for (var changeWord = myWordMatches.length-1; changeWord>=0; changeWord--){          
                        myWord = myWordMatches[changeWord];
                        if (targetNumberOfLines>myStory.lines.length){
                             newWord = loremipsumWord(myWord.contents+"a"); // adds a letter
                        }else if (targetNumberOfLines<myStory.lines.length){
                             newWord = myWord.contents.length>1? loremipsumWord(myWord.contents.slice(0,-1)): myWord.contents; // removes a letter                    
                        } else {
                             return true; // targetNumberOfLines == myStory.lines.length
                        myWord.contents = newWord;
                   if (myNumberOfCharacters == myText.characters.length){
                        return false; // Every word in the text has been reduced to a single character, and the text is still too long.... Give up.
                   } else {
                        myWordMatches = myText.findGrep(); // Need to do a new search, since the text has been changed
         function loremipsumWord(myWord){ // takes a string and returns a random word with same number of letters, and the same capitalization
              var replacementWord = "";
              var correctCaseWord= "";
              var wordLength = myWord.length;
                   if (wordLength >= loremIpsumDictionary.length){ // in case myWord is longer than the longest words in the dictionary
                        replacementWord = loremipsumWord(myWord.substr(0,loremIpsumDictionary.length-1))+loremipsumWord(myWord.substr(loremIpsumDictionary.length-1)); // The word is longer than the longest words in the dictionary. So it's split in two.
                   } else {               
                   replacementWord = loremIpsumDictionary[wordLength][Math.floor(Math.random()*loremIpsumDictionary[wordLength].length)]; // finds a random word of the same length
                   if (myWord.toLowerCase()!=myWord){ // the word contains uppercase characters
                        correctCaseWord = "";
                        for (var n=0; n<wordLength; n++){ // loops through each character in the original word, checking if it's upper or lower case.
                             correctCaseWord += myWord.charAt(n).toUpperCase()==myWord.charAt(n)? replacementWord.charAt(n).toUpperCase(): replacementWord.charAt(n); // makes the character the correct case
                        replacementWord = correctCaseWord;
              return replacementWord;

    Thank you Haakenlid, exactly what I needed now.

Maybe you are looking for

  • Photoshop Elements 5.0--Deactivate

    How do I deactivate Photoshop Elements 5.0 and Premier Elements 3.0? Currently, my computer is not hooked up to the internet--I realize it needs to be before deactivating (not a problem). But when I look at PS Elements or Premier Elements>Help, there

  • Garage Band Claims Audio Files Are In 8-Bit Format And Unusable.

    I've used garageband to make my podcasts for about a year now, with no problems. Sometime in March, though, there were two changes to my setup and I started noticing big problems. The first change was the upgrade to 6.0.5 of garageband, which happene

  • Unable to access nested managed bean property in JSF 1.2.9

    In an old version of JSF, namely 1.2-b20-FCS from April/21/2006, I could access nested properties of a managed bean. So I had a managed bean OuterBean, and in JSF I could write <h:inputText value="#{outerBean.innerBean1.propertyA"/> The Java class Ou

  • I have a legit copy of Adobe 10. Just bought a Mac

    No CD player in the Mac. Where do I go to download this and input the product key instead?

  • Ios 5.0.1 !

    Hello .. I'm from west Bank .. and My iPhone (4)  is originally from the u.s ..  now the problem is that I've upgraded it for ios 5.0.1  .. !! now the old sim i used to use isn't valid ... ( carrier : Jawwal ) ! so any way I've been told that this pr