Skip to content

Commit

Permalink
Updating to current code from AndrewNeo/faextender
Browse files Browse the repository at this point in the history
  • Loading branch information
FallenWolf committed Nov 12, 2014
1 parent 50e2ee2 commit df02ba0
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions src/chrome/content/StoryInGDocs.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,26 @@ if (!com.neocodenetworks.faextender) { com.neocodenetworks.faextender = {}; }
com.neocodenetworks.faextender.StoryInGDocs = {
Bind: function(doc) {
var jQuery = com.neocodenetworks.faextender.Base.getjQuery(doc);

// Reject if already injected
if (jQuery("#__ext_fa_gdoclink").length > 0) return;

// Find injection location
var downloadLink = jQuery("#submission div.actions b a:contains('Download')");
if (downloadLink.length == 0) {
// No download at all
com.neocodenetworks.faextender.Base.logError("Could not find download link, aborting");
return;
}

var downloadLink = com.neocodenetworks.faextender.Base.getDownloadLink(doc, jQuery);
if (!downloadLink) return;

var url = com.neocodenetworks.faextender.Base.getDownloadUrl(doc, jQuery);
if (!url) return;

// Make sure this is a story
if (downloadLink.attr("href").indexOf("stories") < 0) return;
if (url.indexOf("/stories/") < 0) return;

// Get the parent <b>
var dLinkContainer = downloadLink.parent();

// Append new link
jQuery("<span> | <b><a id=\"__ext_fa_gdoclink\" href=\"https://docs.google.com/viewer?url=" + downloadLink.attr("href") + "\">View in GDocs</a></b></span>").insertAfter(dLinkContainer);
jQuery("<span> | <b><a id=\"__ext_fa_gdoclink\" href=\"https://docs.google.com/viewer?url=" + encodeURIComponent(url) + "\">View in GDocs</a></b></span>").insertAfter(dLinkContainer);
}
}

com.neocodenetworks.faextender.Base.registerTarget(com.neocodenetworks.faextender.StoryInGDocs.Bind, "/view/");
com.neocodenetworks.faextender.Base.registerTarget(com.neocodenetworks.faextender.StoryInGDocs.Bind, "/view/");

0 comments on commit df02ba0

Please sign in to comment.