Learn

The forum of documents and methods for studying - Lượm lặt kiến thức


Facebook Comment Expanding Bookmarklet

QaniTri
QaniTri
Admin

Nam Libra Monkey
Tổng số bài gửi : 1566
Tiền xu Ⓑ : 3887
Được cảm ơn № : 6
Ngày khởi sự Ngày khởi sự : 07/01/2013
Đến từ Đến từ : HCMC
Côngviệc / Sởthix Côngviệc / Sởthix : Languages, Softwares, Sciences, Martial arts

facebook - Facebook Comment Expanding Bookmarklet Empty Facebook Comment Expanding Bookmarklet

Bài gửi by QaniTri 22nd January 2017, 14:55

Code:
javascript:(function(){var%20todo=15;
var%20EXPAND_POST=1;
var%20EXPAND_COMMENTS=2;
var%20EXPAND_REPLIES=4;
var%20EXPAND_XLAT=8;
var%20WAIT_TIME=200;
var%20MAX_WAIT=10;
var%20END_DELAY=2.5;
var%20CSS_COMMENT_AREA="UFIList";
var%20ATTR_SHOW_COMMENT_AREA="data-comment-prelude-ref";
var%20CSS_SHOW_COMMENT_AREA="UFIBlingBox";
var%20CSS_SHOW_COMMENT_AREA_2="uiBlingBox";
var%20_NONE="no-value";
var%20_COMMENTS="-comments";
var%20_REPLIES="-replies";
var%20CSS_CONTINUE_READING="text_exposed_link";
var%20CSS_PAGER="UFIPagerLink";
var%20CSS_LINK_TEXT="UFIReplySocialSentenceLinkText";
var%20CSS_SEE_MORE="fss";
var%20CSS_GROUPS_SIDE_MARGIN="groupsSideMargin";
var%20CSS_COMMENT="UFIComment";
var%20CSS_REPLY_LIST="UFIReplyList";
var%20CSS_XLAT_POST="_43f9";
var%20CSS_XLAT_COMMENT="UFITranslateLink";
var%20CSS_XLATED="UFITranslatedText";
var%20CSS_LOGIN_OVERLAY="_5hn6";
var%20CSS_LOGIN_DIALOG="generic_dialog_modal";
var%20CSS_PERMALINK="permalinkPost";
function%20escapeClauseOn(){window.abortNow=false;
document.addEventListener("keyup",docKeyUp);
}function%20escapeClauseOff(){window.abortNow=true;
document.removeEventListener("keyup",docKeyUp);
}function%20docKeyUp(e){if(e.keyCode==27){myLog("Aborting...");
window.abortNow=true;
}}function%20showStatusWindow(){var%20WANT_W=300;
var%20WANT_H=200;
var%20sizer=document.getElementsByTagName("html")[0];
var%20w=sizer.clientWidth;
var%20h=sizer.clientHeight;
var%20x=0;
if(w>WANT_W){x=(w-WANT_W)/2;
}var%20y=0;
if(h>WANT_H){y=(h-WANT_H)/3;
}var%20div=document.createElement("div");
div.id="status-window";
div.style.position="fixed";
div.style.zIndex="999999";
div.style.left=x+"px";
div.style.width=WANT_W+"px";
div.style.top=y+"px";
div.style.height=WANT_H+"px";
var%20container=document.body;
container.insertBefore(div,container.firstChild);
var%20edit=document.createElement("textarea");
edit.style.width="100%";
edit.style.height="100%";
edit.style.color="#fff";
edit.style.backgroundColor="#425f9c";
div.appendChild(edit);
window.g_logger=edit;
escapeClauseOn();
}function%20hideStatusWindow(){var%20div=document.getElementById("status-window");
document.body.removeChild(div);
g_logger=null;
escapeClauseOff();
}function%20myLog(s){console.log(s);
window.g_logger.value=s+"\n"+window.g_logger.value;
}function%20endSession(){if(window.timeouts>0){myLog(window.timeouts+"%20timeout(s)");
}var%20n=window.g_rootNode.getElementsByClassName(CSS_COMMENT).length;
myLog("Number%20of%20comments%20and%20replies%20=%20"+n);
window.setTimeout(hideStatusWindow,END_DELAY*1000);
}function%20determinePageType(){window.g_rootNode=document;
var%20divs=document.getElementsByClassName(CSS_PERMALINK);
if(divs.length===1){myLog("Expanding%20permalinked%20post%20only");
window.g_rootNode=divs[0];
}}function%20getDomSize(){return%20window.g_rootNode.getElementsByTagName("*").length;
}function%20getStyle(node){return%20node.ownerDocument.defaultView.getComputedStyle(node,null);
}function%20isHidden(node){return%20getStyle(node)["display"]=="none";
}function%20hasClassName(node,className){var%20i=node.className.indexOf(className);
if(i<0){return%20false;
}var%20x=node.className.length-className.length;
if(x===0){return%20true;
}if(i===0){return%20node.className.indexOf(className+"%20")===0;
}if(i===x){return%20node.className.indexOf("%20"+className)===(x-1);
}return%20hasClassName(node,"%20"+className+"%20");
}function%20getAncestorByType(node,type,deflt){while(node){node=node.parentNode;
if(node&&node.nodeName==type){return%20node;
}}return%20deflt;
}function%20getAncestorByClass(node,className){while(node){node=node.parentNode;
if(node&&node.className&&hasClassName(node,className)){return%20node;
}}return%20null;
}function%20deleteOverlay(){var%20divs=document.getElementsByClassName(CSS_LOGIN_OVERLAY);
if(divs.length===1){myLog("Removing%20Sign%20Up%20overlay");
divs[0].parentNode.removeChild(divs[0]);
}divs=document.getElementsByClassName(CSS_LOGIN_DIALOG);
if(divs.length===1){myLog("Removing%20login%20dialog");
divs[0].parentNode.removeChild(divs[0]);
}}function%20ensureCommentsShowing(value,onDone){var%20byClass=(value!=null);
var%20showers=byClass?window.g_rootNode.getElementsByClassName(value):window.g_rootNode.getElementsByTagName("A");
var%20filter=[];
for(var%20i=0;
i<showers.length;
i++){if(byClass||showers[i].getAttribute(ATTR_SHOW_COMMENT_AREA)){var%20root=getAncestorByType(showers[i],"FORM",document);
var%20area=root.getElementsByClassName(CSS_COMMENT_AREA);
if(area.length==0){filter.push(showers[i]);
}}}if(filter.length>0){myLog("Showing%20comments%20for%20"+filter.length+"%20post(s)");
clickAndWait(_NONE,onDone,filter,0);
}else{if(onDone)onDone();
}}function%20isHideReplies(link){if(hasClassName(link,CSS_LINK_TEXT)&&link.children.length===1){return%20isNaN(window.parseInt(link.textContent,10));
}return%20false;
}function%20newWindow(link){var%20anchors=link.getElementsByTagName("A");
if(anchors.length>0){var%20target=anchors[0].getAttribute("target");
if(target){myLog("New%20window:%20"+anchors[0].textContent);
var%20w=window.open(anchors[0].getAttribute("href"),target);
if(!w){myLog("New%20window%20was%20blocked!");
}return%20true;
}}return%20false;
}function%20clickClass(value,onDone){if(window.abortNow){if(onDone)onDone();
return;
}var%20links=window.g_rootNode.getElementsByClassName(value);
var%20filter=[];
for(var%20i=0;
i<links.length;
i++){if(value===CSS_CONTINUE_READING){if(getAncestorByClass(links[i],CSS_GROUPS_SIDE_MARGIN)){continue;
}if(!isHidden(links[i])&&links[i].children.length>0){filter.push(links[i].children[0]);
}continue;
}if(value===CSS_XLAT_POST){if(links[i].children.length>0&&links[i].children[0].nodeName==="A"){filter.push(links[i].children[0]);
}continue;
}if(value===CSS_XLAT_COMMENT){if(!getAncestorByClass(links[i],CSS_XLATED)){filter.push(links[i]);
}continue;
}if(isHideReplies(links[i])){}else%20if(value===CSS_SEE_MORE&&links[i].nodeName==="SPAN"){continue;
}else{if(!newWindow(links[i])){filter.push(links[i]);
}}}if(filter.length>0){clickAndWait(value,onDone,filter,0);
}else{if(onDone)onDone();
}}function%20commentsOrReplies(comments,onDone){if(window.abortNow){if(onDone)onDone();
return;
}var%20links=window.g_rootNode.getElementsByClassName(CSS_PAGER);
var%20filter=[];
for(var%20i=0;
i<links.length;
i++){var%20isReply=getAncestorByClass(links[i],CSS_REPLY_LIST)!=null;
if(comments&&!isReply){filter.push(links[i]);
}else%20if(!comments&&isReply){filter.push(links[i]);
}}if(filter.length>0){clickAndWait(comments?_COMMENTS:_REPLIES,onDone,filter,0);
}else{if(onDone)onDone();
}}function%20clickAndWait(value,onDone,links,i){if(window.abortNow){if(onDone)onDone();
return;
}var%20label=links[i].getAttribute("aria-label");
if(!label){label=links[i].textContent;
}myLog("click%20("+(links.length-i-1)+"%20left):%20"+label);
window.domChanged=true;
links[i].click();
var%20n=getDomSize()+(value===_NONE?20:0);
var%20wait=value===CSS_SEE_MORE?0:MAX_WAIT;
window.setTimeout(function(){waitHelper(value,onDone,links,i,n,wait);
},WAIT_TIME);
}function%20waitHelper(value,onDone,links,i,n,wait){if(wait===0||getDomSize()>n){if(++i<links.length){clickAndWait(value,onDone,links,i);
}else{if(wait>0){if(value==_COMMENTS||value==_REPLIES){commentsOrReplies(value==_COMMENTS,onDone);
}else{clickClass(value,onDone);
}}else{window.timeouts++;
if(onDone)onDone();
}}return;
}if(wait!=MAX_WAIT){}window.setTimeout(function(){waitHelper(value,onDone,links,i,n,--wait);
},WAIT_TIME);
}function%20setUpActions(){var%20actions=window.actions=[];
actions.push(function(onDone){ensureCommentsShowing(null,onDone);
});
actions.push(function(onDone){ensureCommentsShowing(CSS_SHOW_COMMENT_AREA,onDone);
});
actions.push(function(onDone){ensureCommentsShowing(CSS_SHOW_COMMENT_AREA_2,onDone);
});
if((todo&EXPAND_POST)!=0){actions.push(function(onDone){clickClass(CSS_CONTINUE_READING,onDone);
});
}if((todo&EXPAND_COMMENTS)!=0){actions.push(function(onDone){commentsOrReplies(true,onDone);
});
}if((todo&EXPAND_REPLIES)!=0){actions.push(function(onDone){clickClass(CSS_LINK_TEXT,onDone);
});
actions.push(function(onDone){commentsOrReplies(false,onDone);
});
}actions.push(function(onDone){clickClass(CSS_SEE_MORE,onDone);
});
if((todo&EXPAND_XLAT)!=0){actions.push(function(onDone){clickClass(CSS_XLAT_POST,onDone);
});
actions.push(function(onDone){clickClass(CSS_XLAT_COMMENT,onDone);
});
}actions.push(function(onDone){window.setTimeout(endSession,window.domChanged?WAIT_TIME:0);
});
actions.push(null);
window.timeouts=0;
window.domChanged=false;
}function%20doActions(i){deleteOverlay();
if(window.actions[i]!=null){window.actions[i](function(){doActions(i+1);
});
}}if(window.g_logger){return;
}showStatusWindow();
determinePageType();
setUpActions();
doActions(0);
})();



    Hôm nay: 10th December 2022, 03:44