Forked from seanlaidlaw/instapaper_bulk_delete_userscript.js
Created
November 16, 2024 14:04
-
-
Save gbarkhatov/6b05ff0c41fad3101b1f2e5d913a2ea8 to your computer and use it in GitHub Desktop.
adds a "Bulk delete" button to instapaper to delete all 40 articles on current page. Requires confirmation before deleting.
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
// ==UserScript== | |
// @name Instapaper Bulk Delete | |
// @namespace https://www.instapaper.com/u | |
// @version 0.1 | |
// @description Provides an option to bulk delete all articles on current page of instapaper | |
// @author Sean Laidlaw | |
// @match https://www.instapaper.com/u | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
// Create the button object | |
var button = document.createElement("button"); | |
button.innerHTML = "Bulk Delete"; | |
// add the button to the top button bar | |
var body = document.getElementsByClassName("top_buttons")[0]; | |
body.appendChild(button); | |
// set all checkboxes and menu buttons as var | |
var chkbox = document.getElementsByClassName('article_selected_indicator'); | |
var menu_buttons = document.getElementsByClassName('js_batch'); | |
// Add event handler to button | |
button.addEventListener ("click", function() { | |
//click on the checkbox next to every article | |
for(var i = 0; i < chkbox.length; i++) { | |
chkbox[i].click(); | |
} | |
//loop through the menu buttons and click when found the delete button | |
for(var i = 0; i < menu_buttons.length; i++) { | |
if (menu_buttons[i].getAttribute('data-action') == "delete") { | |
menu_buttons[i].click(); | |
break; | |
} | |
} | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment