jfsaliba / Act-On - Enable Select All URLs in Segment Filter

// ==UserScript==
// @name         Act-On - Enable Select All URLs in Segment Filter
// @namespace    https://openuserjs.org/users/jfsaliba
// @version      1.2
// @description  Makes it possible to mass check/uncheck URL selections that are currently visible when choosing web pages in segment filters
// @author       James Saliba
// @homepageURL  https://github.com/jfsaliba
// @license      Attribution-ShareAlike 4.0 International (CC BY-SA 4.0); http://creativecommons.org/licenses/by-sa/4.0/
// @match        http://*.actonsoftware.com/acton/ng-ui/
// @grant        none
// ==/UserScript==

var GO_WebPageAll = function(){
    
        ///////////SCRIPT STARTS HERE//////////////////////

        if($('#content').contents().find('#editFrame').contents().find('#checkbtn_WebPageAll').length <= 0) {
			$('#content').contents().find('#editFrame').contents().find('#searchGo').after('<a href="#" id="checkbtn_WebPageAll" style="float: right;display: inline-block;padding: 3px 7px;margin-bottom: 0;font-size: 12px;font-weight: 400;line-height: 1.42857143;text-align: center;white-space: nowrap;vertical-align: middle;-ms-touch-action: manipulation;touch-action: manipulation;cursor: pointer;-webkit-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;background-image: none;border: 1px solid transparent;border-radius: 4px;color: #fff;background-color: #5cb85c;border-color: #4cae4c;">(De)Select all visible</a>');
			
			$('#content').contents().find('#editFrame').contents().find('#chooserDialog').on('click','#checkbtn_WebPageAll',function(){
				var chkBoxes = $('#content').contents().find('#editFrame').contents().find('#webpagelist input[type="checkbox"]:visible');
				chkBoxes.prop('checked',!chkBoxes.prop('checked')).change();
			});
		}

        ///////////SCRIPT ENDS HERE//////////////////////

}

var start_WebPageAll = function() {
	
	if($('#content').contents().find('#editFrame').contents().find('#webpagelist').is(':visible')) {
		GO_WebPageAll();
	} else {
		//unbind
		$('#content').contents().find('#editFrame').contents().find('#chooserDialog').off('click','#checkbtn_WebPageAll');
		if($('#content').contents().find('#editFrame').contents().find('#checkbtn_WebPageAll').length > 0) {
			$('#content').contents().find('#editFrame').contents().find('#checkbtn_WebPageAll').remove();
		}
	}    

    setTimeout(function(){
        start_WebPageAll();
    },1000);
}

start_WebPageAll();