Created
July 5, 2017 08:49
-
-
Save bowbowbow/8c8815cff401c9162c3503299ac456c0 to your computer and use it in GitHub Desktop.
fb_posting_remover extension
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fireEvent = function (element, event) { | |
if (document.createEventObject) { | |
var evt = document.createEventObject(); | |
return element.fireEvent("on" + event, evt); | |
} else { | |
var evt = document.createEvent("HTMLEvents"); | |
evt.initEvent(event, true, true); | |
return !element.dispatchEvent(evt); | |
} | |
}; | |
//Fires the click event | |
jQuery.fn.fclick = function () { | |
$(this).each( function() { | |
fireEvent(this, "click"); | |
}); | |
}; | |
function delay(timer, callback ) { | |
setTimeout(function () { | |
callback(); | |
}, timer); | |
}; | |
var atag = []; | |
function run(idx) { | |
if(idx >= atag.length) { | |
location.reload(); | |
return; | |
} | |
var a = atag[idx]; | |
$(a).fclick(); | |
delay(1000, function () { | |
try { | |
$($('.uiContextualLayerBelowRight')[idx]).find('a')[2].click(); | |
if($($($('.uiContextualLayerBelowRight')[idx]).find('a')[2]).text() != '삭제') { | |
throw new Error("clicked button doesn't have text 삭제"); | |
} | |
delay(4000, function () { | |
var button_txt = $($('form')[1]).find('button').text(); | |
if(button_txt == "게시물 삭제") { | |
$($('form')[1]).find('button').click() | |
delay(6000, function () { | |
run(idx+1); | |
}); | |
} else { | |
location.reload(); | |
} | |
}); | |
} catch(e) { | |
console.log('error : ', e); | |
run(idx+1); | |
} | |
}); | |
} | |
function scroll(second) { | |
if(second > 90) { | |
$('table').find('a').each(function () { | |
var label = $(this).attr('aria-label'); | |
if(label == '수정') { | |
atag.push($(this)); | |
} | |
}); | |
run(0); | |
return; | |
} | |
delay(1500, function() { | |
$('html,body').scrollTop(1000000000); | |
scroll(second+1); | |
}); | |
} | |
console.log('::fb remover:: loaded'); | |
if (document.URL.indexOf('sk=allactivity') != -1) { | |
console.log('::fb remover:: run'); | |
scroll(0); | |
setTimeout(function () { | |
location.reload(); | |
}, 1000*60*5); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment