diff --git a/inject.min.js b/inject.min.js new file mode 100644 index 0000000..f6dbaf7 --- /dev/null +++ b/inject.min.js @@ -0,0 +1 @@ +function strip(a){var t=document.createElement("div");t.innerHTML=a;var e=t.textContent||t.innerText||"";return e.replace(/['"]/g,"")}function buildBookmarkTag(a,t,e,o){var n=$(""+bookmarkLabel+"");n.attr("data-username",t).attr("data-content",e).attr("data-link",o).attr("href","#").addClass(bookmarkClass),chrome.runtime.sendMessage({action:"checkIfBookmarkExists",link:o},function(t){t.exists&&n.addClass(bookmarkedClass).html(bookmarkedLabel),a.find(".faveit").remove(),a.find(".favedit").remove(),a.append(n.wrap("
").parent().html())})}var bookmarkLabel="☆ FaveIt",bookmarkedLabel="★ Fav'd",bookmarkClass="faveit",bookmarkedClass="favedit";$(function(){$("."+bookmarkClass).off("click","**"),$(document).on("click","."+bookmarkClass,function(){var a=$(this).attr("data-username"),t=$(this).attr("data-content"),e=$(this).attr("data-link"),o=this;e.length>0&&("/"===e[0]&&(e=window.location.origin+e),chrome.runtime.sendMessage({action:"addFbBookmark",username:a,content:t,link:e},function(a){$(o).html(bookmarkedLabel).addClass(bookmarkedClass)}))}),$(document).on("click","."+bookmarkedClass,function(){var a=$(this).attr("data-username"),t=$(this).attr("data-content"),e=$(this).attr("data-link"),o=this;chrome.runtime.sendMessage({action:"checkIfBookmarkExists",username:a,content:t,link:e},function(a){chrome.runtime.sendMessage({action:"removeFbBookmark",id:a.nodes[0].id},function(a){$(o).html(bookmarkLabel).removeClass(bookmarkedClass)})})})});