Last active
August 14, 2020 12:01
-
-
Save hoshsadiq/85199ffda1c341e68a244f550f6cbce0 to your computer and use it in GitHub Desktop.
User Scripts
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 AWS SAML login auto-submit | |
// @namespace https://gist.github.com/hoshsadiq/aws-saml-auto-submit | |
// @match https://signin.aws.amazon.com/saml | |
// @grant none | |
// @version 1.0 | |
// @author hoshsadiq | |
// @description Automatically submit the form when a role is selected on the AWS SAML login page. | |
// ==/UserScript== | |
(function () { | |
window.addEventListener('load', () => { | |
[].forEach.call( | |
document.querySelectorAll('#saml_form input[name=roleIndex]'), | |
el => { | |
el.onclick = () => { | |
el.form.submit(); | |
} | |
} | |
); | |
}, false); | |
})() |
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 GitHub Clubhouse Linking | |
// @author @hoshsadiq | |
// @website https://github.com/hoshsadiq/clubhouse-github-linker | |
// @namespace https://github.com/hoshsadiq/clubhouse-github-linker | |
// @license MIT | |
// @description This userscript will link clubhouse issue ids ([chXXX]) in PRs and commit pages | |
// @version 0.1.0 | |
// @include https://github.com/*/* | |
// ==/UserScript== | |
(function (w, d) { | |
const CH_STORY_URL = 'https://app.clubhouse.io/story/'; | |
const CH_STORY_REGEX = /\[ch(\d+)\]/ | |
const update = function replaceClubhouseLink(node) { | |
if (node.nodeName === 'A') { | |
return; // Already a link | |
} | |
const id = node.innerText.match(CH_STORY_REGEX); | |
if (!id) { | |
return; // Not a valid Clubhouse story reference | |
} | |
const link = d.createElement('a'); | |
link.href = CH_STORY_URL + id[1]; | |
link.innerText = id[0]; | |
link.setAttribute('target', '_blank'); | |
node.innerHTML = node.innerHTML.replace(id[0], link.outerHTML); | |
}; | |
const changed = function onLocationChange() { | |
const is_pull = /\/pull\//.test(w.location.pathname); | |
const is_commit = /\/commit\//.test(w.location.pathname); | |
if (!is_pull && !is_commit) { | |
return; // Only operate on PRs and commits (for now) | |
} | |
const context = is_pull ? d.querySelectorAll('.js-issue-title, .comment-body > *') : d.querySelectorAll('.js-issue-title, .full-commit > *'); | |
const nodes = Array.prototype.filter.call(context, function (element) { | |
return RegExp(CH_STORY_REGEX).test(element.textContent); | |
}); | |
nodes.forEach(update); | |
}; | |
changed(); | |
d.addEventListener('pjax:end', changed); | |
})((unsafeWindow || window), document); |
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 Reddit Overwrite | |
// @namespace Reddit | |
// @description Overwrites your Reddit comments to protect people from stalking, doxxing, and profiling you. Also, Reddit does not truly delete anything, but since they don't keep versions this better protects you. To use it, login to Reddit, click your username, go to comments, click on the OVERWRITE button. It is MUCH more efficient if you use RES and scroll to your oldest comment. If you are migrating accounts, you can move your subs by going to reddit.com/subreddits, and copying the link on the right. | |
// @include https://*.reddit.com/* | |
// @include http://*.reddit.com/* | |
// @version 1.4.8 | |
// @run-at document-start | |
// ==/UserScript== | |
unsafeWindow.to_delete = []; | |
unsafeWindow.num_user_comments = 0; | |
unsafeWindow.deleted = 0; | |
unsafeWindow.span = ''; | |
unsafeWindow.user = ''; | |
unsafeWindow.delete_comment = function(thing_id, from_delete_all) | |
{ | |
try{ | |
var thing = document.querySelector("input[name='thing_id'][value='" + thing_id + "']"); | |
var status = thing.parentNode.querySelector("div.usertext-edit > div.bottom-area > div.usertext-buttons > span.status").innerHTML; | |
var error = false; | |
if ((status.indexOf("error") != -1) || (status.indexOf("submitting") != -1)){ | |
error = true; | |
} else { | |
// var del_form = thing.parentNode.parentNode.querySelector("ul.buttons > li > form.del-button"); | |
// unsafeWindow.toggle(del_form.querySelector("span.main > a")); | |
// del_form.querySelector("span.error > a.yes").click(); | |
unsafeWindow.deleted++; | |
} | |
if (from_delete_all){ | |
if (unsafeWindow.to_delete.length != 0) | |
{ | |
unsafeWindow.span.innerHTML = "OVERWRITING COMMENT " + (unsafeWindow.deleted + 1) + " OF " + unsafeWindow.num_user_comments; | |
var next_thing_id = unsafeWindow.to_delete.pop(); | |
unsafeWindow.setTimeout(unsafeWindow.overwrite_comment, 2000, next_thing_id, from_delete_all); | |
} | |
else | |
{ | |
if (unsafeWindow.num_user_comments - unsafeWindow.deleted != 0){ | |
unsafeWindow.num_user_comments = unsafeWindow.num_user_comments - unsafeWindow.deleted; | |
UpdateDeleteAllSpan(); | |
unsafeWindow.span.innerHTML = "<span>Failed to overwrite " + unsafeWindow.num_user_comments + " comments</span><br>" + unsafeWindow.span.innerHTML; | |
} else | |
unsafeWindow.span.style.display = 'none'; | |
} | |
} else { | |
if (error) | |
alert("Failed to overwrite your comment. Overwrite aborted."); | |
else | |
unsafeWindow.num_user_comments--; | |
UpdateDeleteAllSpan(); | |
} | |
return (error ? -1 : 0); | |
}catch(er){ | |
alert(er); | |
if (from_delete_all) unsafeWindow.location.reload(); | |
return -99; | |
} | |
} | |
unsafeWindow.overwrite_comment = function(thing_id, from_delete_all) | |
{ | |
try{ | |
var edit_form = document.querySelector("input[name='thing_id'][value='" + thing_id + "']").parentNode; | |
edit_form.querySelector("div.usertext-edit > div.bottom-area > div.usertext-buttons > button.cancel").click(); | |
var edit_btn = edit_form.parentNode.querySelector("ul > li > a.edit-usertext"); | |
if (edit_btn) edit_btn.click(); | |
var edit_textbox = edit_form.querySelector("div.usertext-edit > div > textarea"); | |
var repl_str = ''; | |
var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz><.-,+!#$%^&*();:[]~"; | |
// for(var x = 0; x < edit_textbox.value.length; x++){ | |
// if (edit_textbox.value.substr(x,1) == '\n'){ | |
// repl_str += '\n'; | |
// }else{ | |
// var rnum = Math.floor(Math.random() * chars.length); | |
// repl_str += chars.charAt(rnum, 1); | |
// } | |
// } | |
var sumting = '^^^^^^^^^^^^^^^^' + Math.random(); | |
var sumtingtr = sumting.substring(0,22); | |
var sumting2 = '' + Math.random(); | |
var sumtingtr2 = sumting2.substring(2,7); | |
edit_textbox.value = "deleted " + sumtingtr + " [^^^What ^^^is ^^^this?](https://pastebin.com/FcrFs94k/" + sumtingtr2 + ")"; | |
edit_form.querySelector("div.usertext-edit > div.bottom-area > div.usertext-buttons > button.save").click(); | |
unsafeWindow.setTimeout(unsafeWindow.delete_comment, 2000, thing_id, from_delete_all); | |
return 0; | |
}catch(e){ | |
alert("Error interacting with overwrite form: " + e); | |
return -99; | |
} | |
}; | |
unsafeWindow.delete_all = function() | |
{ | |
try{ | |
unsafeWindow.num_user_comments = 0; | |
unsafeWindow.deleted = 0; | |
unsafeWindow.to_delete = []; | |
var comments = document.querySelectorAll("a.author"); | |
for (var i = 0; i < comments.length; i++) | |
{ | |
if (comments[i].innerHTML != unsafeWindow.user) continue; | |
var thing_id = comments[i].parentNode.parentNode.querySelector("form.usertext > input[name='thing_id']").value; | |
if (unsafeWindow.to_delete.indexOf(thing_id) == -1){ | |
unsafeWindow.to_delete.push(thing_id); | |
unsafeWindow.num_user_comments++; | |
} | |
} | |
unsafeWindow.span.innerHTML = "TRYING TO Overwrite COMMENT 1 OF " + unsafeWindow.num_user_comments; | |
var next_thing_id = unsafeWindow.to_delete.pop(); | |
unsafeWindow.overwrite_comment(next_thing_id, true); | |
} catch(e){ | |
alert("YOU ARE MOST LIKELY NOT ON THE COMMENTS TAB! /n/n Error trying to delete all your comments.\nError: " + e + " Stack:" + e.stack); | |
unsafeWindow.location.reload() | |
} | |
}; | |
function add_delete_links(ev) | |
{ | |
unsafeWindow.user = document.querySelector("span.user > a:not(.login-required)").innerHTML; | |
if (!unsafeWindow.user){return;} | |
var comments = document.querySelectorAll("a.author"); | |
unsafeWindow.num_user_comments = 0; | |
for (var i = 0; i < comments.length; i++) | |
{ | |
if (comments[i].innerHTML != unsafeWindow.user) continue; | |
try{ | |
var main_parent = comments[i].parentNode.parentNode; | |
var thing_id = main_parent.querySelector("form > input[name='thing_id']").value; | |
var list = main_parent.querySelector("ul.flat-list"); | |
if (list.querySelector("li.secure_delete")) continue; | |
unsafeWindow.num_user_comments++; | |
var addedlink = document.createElement("li"); | |
addedlink.setAttribute('class', 'secure_delete'); | |
var dlink = document.createElement("a"); | |
dlink.setAttribute('class','bylink secure_delete'); | |
dlink.setAttribute('onClick','javascript:var ret = overwrite_comment("' + thing_id + '", false);'); | |
dlink.setAttribute('href', 'javascript:void(0)'); | |
// dlink.appendChild(document.createTextNode('SECURE DELETE')); | |
addedlink.appendChild(dlink); | |
main_parent.querySelector("ul.flat-list").appendChild(addedlink); | |
}catch(e){} | |
} | |
unsafeWindow.span = document.createElement("span"); | |
unsafeWindow.span.setAttribute('class', 'nextprev secure_delete_all'); | |
UpdateDeleteAllSpan(); | |
} | |
function UpdateDeleteAllSpan() | |
{ | |
if (unsafeWindow.num_user_comments){ | |
unsafeWindow.span.innerHTML = ""; | |
var dlink = document.createElement("a"); | |
dlink.setAttribute('class','bylink'); | |
dlink.setAttribute('onClick','javascript:return delete_all()'); | |
dlink.setAttribute('href', 'javascript:void(0)'); | |
dlink.appendChild(document.createTextNode('OVERWRITE ALL visible comment(s) on this page - MAKE SURE YOU ARE ON THE COMMENTS TAB. It is also HIGHLY recommended to use Reddit Enhancement Suite with the Never Ending Reddit feature to extend the comments as far down as possible.')); | |
unsafeWindow.span.appendChild(dlink); | |
document.querySelector("div.content").insertBefore(unsafeWindow.span,document.querySelector("div.content").firstChild); | |
} else if (unsafeWindow.span != null) { | |
unsafeWindow.span.style.display = 'none'; | |
} | |
} | |
window.addEventListener("DOMContentLoaded",add_delete_links, false); |
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 Torrentz2 Magnet | |
// @namespace tzeumg | |
// @description Add magnet link to torrentz2 | |
// @include https://torrentz2.eu/* | |
// @include https://torrentz2.me/* | |
// @include https://torrentz2.is/* | |
// @version 2.3 | |
// @grant GM_addStyle | |
// ==/UserScript== | |
(function () { | |
const downloadText = "🧲"; | |
const defaultTrackers = [ | |
"udp://tracker.sktorrent.net:6969/announce", | |
"udp://tracker.coppersurfer.tk:6969/announce", | |
"http://www.opentrackr.org/announce", | |
"udp://tracker.leechers-paradise.org:6969/announce", | |
"udp://tracker.zer0day.to:1337/announce", | |
"http://bt.artvid.ru:6969/announce", | |
]; | |
function parse_trackers(trackers) { | |
if (trackers.length > 0) { | |
return "&tr=" + trackers.join("&tr=") | |
} | |
return "" | |
} | |
function getMagnetAnchor(hash, dn, trackers) { | |
const magnetLink = document.createElement("a"); | |
magnetLink.href = "magnet:?xt=urn:btih:" + hash + "&dn=" + dn + parse_trackers(trackers); | |
magnetLink.style.fontWeight = "bold"; | |
magnetLink.innerHTML = downloadText; | |
return magnetLink | |
} | |
function add_magnet_link(el, hash, dn, trackers) { | |
const separator = document.createTextNode(' '); | |
el.parentNode.insertBefore(separator, el); | |
el.parentNode.insertBefore(getMagnetAnchor(hash, dn, trackers), separator); | |
} | |
const path = document.location.pathname | |
if (["/verified", "/search", "/my"].indexOf(path) !== -1) { | |
const dtList = document.querySelectorAll('.results > dl> dt'); | |
for (let i = 0; i < dtList.length; i++) { | |
if (dtList[i].classList.contains("dmca")) { | |
continue | |
} | |
let el = dtList[i].firstChild; | |
let hash = el.href.split('/').pop(); | |
let dn = el.innerHTML; | |
add_magnet_link(el, hash, dn, defaultTrackers); | |
} | |
} else if (/^\/[a-f0-9]{40}$/.test(path)) { | |
let hash = window.location.href.split('/').pop(); | |
let torrentTitle = document.querySelector(".downurls > h2 > span"); | |
let dn = torrentTitle.innerText.trim(); | |
let trackers = [].map.call( | |
document.querySelectorAll('.trackers > dl > dt'), | |
function (tr) { | |
return tr.innerText.trim() | |
} | |
); | |
add_magnet_link(torrentTitle, hash, dn, trackers); | |
} | |
})() |
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 Automatically redirect to Zoom Web Client | |
// @description Always show the web client link on zoom.us meeting join pages, even if the host has asked Zoom to hide it by default. | |
// @version 1.1 | |
// @grant none | |
// @include https://zoom.us/j/* | |
// @include https://*.zoom.us/j/* | |
// @include https://zoom.us/s/* | |
// @include https://*.zoom.us/s/* | |
// @namespace https://gist.github.com/hoshsadiq/zoomus-web-client-redirect | |
// ==/UserScript== | |
(function() { | |
const href = document.querySelector(".webclient a").getAttribute('href') | |
if (href.startsWith("http")) { | |
window.location = href | |
} else { | |
window.location.pathname = href | |
} | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment