URL Expansion does not always work. What gives?
The URL expansion depends on http://LongURL.org if that service goes down, URL expansion ceases to function.
To mitigate this issue, I try to diversify services used for URL expansion.
e.g. TinyURL & Bit.ly use their API's to expand their URLs.
However I can't cover every URL expansion service there is.
To mitigate this issue, I try to diversify services used for URL expansion.
e.g. TinyURL & Bit.ly use their API's to expand their URLs.
However I can't cover every URL expansion service there is.
2
people have this question
I have this question, too!
Tell me when someone answers.
The more people who ask this question, the more it gets noticed.
The more people who ask this question, the more it gets noticed.
Create a customer community for your own organization
Plans starting at $19/month
-
Inappropriate?Preferring that kind of thing to work across the entire web, I tend to use a separate script for that -- http://userscripts.org/scripts/show/4..., to be quite precise. Though I run that script before yours, it seems to break, whether your Twitter helper is set to do URL expansion or not.
Does your off mode still do something wonky with the node structure around links; change innerHTML, or the like? I think your script might be better off suggesting some external specialized script for this kind of feature -- rather than implementing that part on its own (and likely a bit more left-handedly). -
I will try to improve this area. I want to avoid hitting linked sites as that can mess up statistics.
The dom is changed a lot on twitter through pagination/search etc. and the script you mention only expands links it first sees not ones loaded in dynamically. -
Inappropriate?It actually expands them after page changes too, though it might not have the day I posted the comment. You'll note the "expanding url; one moment..." tooltip it adds to tinyurls before it's received a response on poking through, but with Troys Twitter Script active, it never manages to update the link, because you kill that link node my script holds a reference to, when you replace innerHTML via $content.html($content.html().replace...) in linkify(), in search of hash tags.
If you'd remove (or make disable:able) that, and the $tweet.find('.entry-content a[rel=nofollow]') replace-link-text-with-href, your script will interoperate much, much better with other scripts. -
I'm not sure of a way to link hash tags without changing the DOM. Is there a way for you todo a xpath search for links with the href you just expanded? e.g. \\a[href=TINYURL] ... this way there isn't a race condition.
I'll offer an option to disable hash tag linking. -
Inappropriate?Oh, I'm not requesting you to stop changing the DOM, just not changing nodes you aren't interested in -- seek out just the text nodes you want and replace them with text+link+text where you find a hash tag, and things will be fine.
For instance, the text node "xxx #hash yyy" becoming the three nodes #text:"xxx ", a:"#hash", #text:" yyy" afterward, which will not interfere with adjacent links that other scripts may be poking around with.
Seeking out './/text()[contains("#")]' in the comment will get you just the text nodes you want. To replace it, do something like (using my tiny convenience XPath lib http://ecmanaut.googlecode.com/svn/tr...$x$X.js as I'm not sure jQuery handles XPath):
$x('.//text()[contains("#")]', tweetNode).forEach(function(text) {
var match = /( |^)\#([a-zA-Z0-9.]+)/gi.exec(text.nodeValue);
if (!match) return; // wasn't a hash tag
var before = document.createTextNode(RegExp.leftContext + match[1] + "#");
var after = document.createTextNode(RegExp.rightContext);
var link = document.createElement("a");
a.href = "http://search.twitter.com/search?q=%23" + match[2];
a.textContent = match[2];
/// other decorations you want
var linked = document.createDocumentFragment();
linked.appendChild(before);
linked.appendChild(link);
linked.appendChild(after);
text.parentNode.replaceChild(text, linked);
});
Not tested, but probably close to working, barring some typo or similar. -
Whoa; the site's autolinkification broke things a bit there -- this lib implements the $x used in my example. -
I'll give it a shot. I'm not sure if I'll get this in the next round, but I'll def be looking at it. -
Inappropriate?If doing it the right way, like above, is too much work, would you consider just not touching the html when you didn't actually find a hash tag? As in:
var was = $content.html();
var hashlinks = was.replace(...);
if (was != hashlinks)
$content.html(hashlinks);
That would cut down the breakage to messages with both links and hash tags.
I’m frustrated
-
I added that snippet to the code, and added an option to disable hash tags as well.
Loading Profile...


EMPLOYEE
