Last active
November 21, 2023 23:44
-
-
Save oneross/b4679f3993cc9c05f9b6b1db5fd67ed6 to your computer and use it in GitHub Desktop.
Bookmarklet - Copy full contents of dom to clipboard
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
javascript:(function() { | |
var element = document.createElement('textarea'); | |
element.textContent = document.documentElement.outerHTML; | |
document.body.appendChild(element); | |
element.select(); | |
document.execCommand('copy'); | |
document.body.removeChild(element); | |
alert('DOM copied to clipboard!'); | |
})(); |
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
javascript:(function() { | |
var htmlContent = document.documentElement.outerHTML; | |
var emailRegex = /([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+)/gi; | |
var emails = htmlContent.match(emailRegex); | |
var uniqueEmails = emails ? Array.from(new Set(emails)) : []; | |
if (uniqueEmails.length > 0) { | |
var element = document.createElement('textarea'); | |
element.textContent = uniqueEmails.join('\n'); | |
document.body.appendChild(element); | |
element.select(); | |
document.execCommand('copy'); | |
document.body.removeChild(element); | |
alert('Emails copied to clipboard!'); | |
} else { | |
alert('No emails found!'); | |
} | |
})(); |
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
javascript:(function() { | |
var action = prompt("Choose action: 'Create' or 'Add'"); | |
if (!action || (action !== 'Create' && action !== 'Add')) { | |
alert('Invalid action. Please enter either "Create" or "Add".'); | |
return; | |
} | |
var userNameElement = document.querySelector('h3.userName'); | |
var userName = userNameElement ? `'${userNameElement.textContent.trim()}'` : null; | |
var images = Array.from(document.querySelectorAll('img[fullname]')); | |
var userNameIndex = images.findIndex(img => img.getAttribute('fullname') === userName.replace(/'/g, "")); | |
var relations = []; | |
if (userName && userNameIndex !== -1) { | |
images.forEach((img, index) => { | |
var fullname = `'${img.getAttribute('fullname')}'`; | |
if (index < userNameIndex) { | |
var reportTo = index === 0 ? "''" : `'${images[index - 1].getAttribute('fullname')}'`; | |
relations.push(`(${fullname}, ${reportTo}, 'reports-to')`); | |
} else if (index > userNameIndex) { | |
relations.push(`(${fullname}, ${userName}, 'reports-to')`); | |
} | |
}); | |
if (relations.length > 0) { | |
var element = document.createElement('textarea'); | |
element.textContent = relations.join('\n'); | |
document.body.appendChild(element); | |
element.select(); | |
if (action === 'Add') { | |
var existingContent = ''; | |
try { | |
existingContent = window.clipboardData.getData('Text') || ''; | |
} catch (e) { | |
// Accessing clipboard can be restricted in some browsers | |
} | |
element.textContent = existingContent + element.textContent; | |
element.select(); | |
} | |
document.execCommand('copy'); | |
document.body.removeChild(element); | |
alert('Relations copied to clipboard!'); | |
} else { | |
alert('No relations found!'); | |
} | |
} else { | |
alert('User name not found or no images with fullname attribute!'); | |
} | |
})(); |
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
import networkx as nx | |
import matplotlib.pyplot as plt | |
# Assuming org_structure is a list of tuples in the form (manager, managee, 'reports-to') | |
org_structure = [('person1', 'person2', 'reports-to'), ('person2', 'person3', 'reports-to')] | |
G = nx.DiGraph() | |
G.add_edges_from([(x[0], x[1]) for x in org_structure]) | |
pos = nx.spring_layout(G) | |
nx.draw_networkx_nodes(G, pos) | |
nx.draw_networkx_edges(G, pos) | |
nx.draw_networkx_labels(G, pos) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment