Created
February 27, 2020 15:03
-
-
Save oddrationale/7be0948018c033b5f5082d58b1ee64f7 to your computer and use it in GitHub Desktop.
This file contains 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
(function(e, s) { | |
e.src = s; | |
e.onload = function() { | |
jQuery.noConflict(); | |
jQuery('<style type="text/css"> .remove { opacity:0.3;}\n .urlmodal {padding: 10px; background-color: #eee; position: fixed; bottom: 0; right: 0; height: 200px; width: 300px; z-index: 1000;} .urlmodal textarea {width: 100%; height: 140px;}</style>').appendTo('head'); | |
jQuery('<div class="urlmodal"><h3>Let\'s create a dataset</h3><textarea>Scoll all the way down\nClick "Show more images"\nScroll more\nClick on the images you want to remove from the dataset\nThe urls will appear in this box for you to copy.</textarea></div>').appendTo('body'); | |
jQuery('.urlmodal textarea').focus(function() {updateUrls(); setTimeout(selectText, 100)}).mouseup(function() {return false;}); | |
jQuery(window).scroll(function() { | |
toggle(); | |
updateUrls(); | |
}); | |
function toggle() { | |
jQuery('.rg_i').on('click', function() {jQuery(this).toggleClass('remove'); updateUrls(); return false;}); | |
} | |
function updateUrls() { | |
var urls = Array.from(document.querySelectorAll(".rg_i:not(.remove)")).map(el=>el.hasAttribute("data-src")?el.getAttribute("data-src"):el.getAttribute("data-iurl")).filter(l=>l!=null); | |
var search_term = jQuery('[title=Search]').val(); | |
jQuery('.urlmodal textarea').val(urls.join("\n")); | |
jQuery('.urlmodal h3').html(search_term + ": " + urls.length); | |
} | |
function selectText() { | |
jQuery('.urlmodal textarea').select(); | |
} | |
}; | |
document.head.appendChild(e); | |
})(document.createElement('script'), '//code.jquery.com/jquery-latest.min.js'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment