Skip to content

Instantly share code, notes, and snippets.

@ziyunli
Created July 5, 2022 01:28
Show Gist options
  • Save ziyunli/2925a03d3c92c89cf5d5223ec2918ca1 to your computer and use it in GitHub Desktop.
Save ziyunli/2925a03d3c92c89cf5d5223ec2918ca1 to your computer and use it in GitHub Desktop.
OneTab Operations
with open('onetab.txt', encoding="utf-8") as f:
with open('dedup.txt', 'w', encoding="utf-8") as out:
links = {}
is_linebreak = False
for line in f:
line = line.strip()
if not line:
if not is_linebreak:
out.write('\n')
is_linebreak = True
continue
tokens = [x.strip() for x in line.split(' | ', 1)]
url = tokens[0]
title = tokens[-1]
if url in links:
continue
links[url] = title
out.write(url + ' | ' + title + '\n')
is_linebreak = False
function delete_single() {
for (clickable of clickables) {
if (!clickable || clickable.innerHTML !== "Delete all")
continue;
clickable.click();
return true;
}
return false;
}
window.confirm = function() { return true; }
var clickables = document.getElementsByClassName("clickable");
document.addEventListener('DOMNodeRemoved', delete_single, false);
delete_single();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment