Created
January 12, 2014 18:52
-
-
Save patik/8388768 to your computer and use it in GitHub Desktop.
Displays magnet links and other P2P URLs prominently. Great for sites that hide the real links between obnoxious "download" ad banners or open pop ups when you click on them.
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
// ==UserScript== | |
// @name Magnet Link Finder | |
// @description Finds all magnet URLs and displays them prominently | |
// @namespace http://patik.com/code/user-scripts/ | |
// @include * | |
// @version 1.0.0.20140112 | |
// ==/UserScript== | |
(function _magnet_links() { | |
var linkList = null, // Display list that holds the links | |
magnetAnchors = [], // List of all found P2P anchors | |
// Run the plugin | |
init = function _init() { | |
findAnchors(); | |
if (magnetAnchors.length) { | |
createDisplay(); | |
displayAnchors(); | |
} | |
}, | |
/** | |
* Find anchor elements that point to P2P links | |
*/ | |
findAnchors = function _findAnchors() { | |
var magSelector = 'a[href^="magnet:"], a[href^="ed2k://"], a[href^="thunder://"], a[href^="flashget://"], a[href^="qqdl://"]', | |
hostURL = window.location.host; | |
// For some sites we know which link to keep and which to disregard (e.g. keep the link for a file set, but disregard links for individual files) | |
// Pirate Bay | |
if (hostURL.indexOf('thepiratebay') !== -1 || hostURL.indexOf('baymirror.com') !== -1) { | |
magnetAnchors.push(document.querySelector('.download ' + magSelector)); | |
} | |
// Kickass.to | |
if (hostURL.indexOf('kickass.to') !== -1) { | |
magnetAnchors.push(document.querySelector('.magnetlinkButton')); | |
} | |
// Other sites | |
else { | |
// Get all links | |
magnetAnchors = magnetAnchors.concat([].slice.call(document.querySelectorAll(magSelector))); | |
} | |
}, | |
/** | |
* Add all found anchors to the display | |
*/ | |
displayAnchors = function displayAnchors() { | |
magnetAnchors.forEach(function (magnet) { | |
var listItem = document.createElement('li'), | |
anchor = document.createElement('a'), | |
input = document.createElement('input'); | |
anchor.href = magnet.href; | |
anchor.innerHTML = magnet.innerText || magnet.getAttribute('title') || 'Link'; | |
input.type = 'url'; | |
input.value = magnet.href; | |
// Create list item | |
listItem.appendChild(anchor); | |
listItem.appendChild(document.createElement('br')); | |
listItem.appendChild(input); | |
// Add list item to the list | |
linkList.appendChild(listItem); | |
}); | |
}, | |
/** | |
* Create a display area to hold the links | |
*/ | |
createDisplay = function _createDisplay() { | |
var container = document.createElement('div'), | |
cssRules = '', | |
style; | |
// Outer container | |
container.id = 'magnet-link-list'; | |
cssRules += '#magnet-link-list {'; | |
cssRules += 'position: absolute;'; | |
cssRules += 'top: 1em;'; | |
cssRules += 'right: 1em;'; | |
cssRules += 'width: 20em;'; | |
cssRules += 'minHeight: 4em;'; | |
cssRules += 'padding: 0.75em;'; | |
cssRules += 'background-color: #fff;'; | |
cssRules += 'z-index: 10001;'; | |
cssRules += 'border: 1px solid #777;'; | |
cssRules += 'box-shadow: 1px 1px 6px #aaa;'; | |
cssRules += 'font: 16px/1.4 "Open Sans", "Helvetica Neue", sans-serif;'; | |
cssRules += 'color: #444;'; | |
cssRules += '}'; | |
// Header | |
container.innerHTML = '<h1>Magnet Links</h1>'; | |
cssRules += '#magnet-link-list h1 {'; | |
cssRules += 'font: 20px/1.4 "Open Sans", "Helvetica Neue", sans-serif;'; | |
cssRules += 'margin-top: 0em;'; | |
cssRules += 'text-align: center;'; | |
cssRules += '}'; | |
// List of links | |
linkList = document.createElement('ul'); | |
cssRules += '#magnet-link-list ul {'; | |
cssRules += 'list-style: none outside none;'; | |
cssRules += 'margin-left: 0;'; | |
cssRules += '-webkit-padding-start: 0;'; | |
cssRules += '-moz-padding-start: 0;'; | |
cssRules += '}'; | |
cssRules += '#magnet-link-list li {'; | |
cssRules += 'margin-bottom: 1em'; | |
cssRules += '}'; | |
cssRules += '#magnet-link-list li:last-child {'; | |
cssRules += 'margin-bottom: 0'; | |
cssRules += '}'; | |
cssRules += '#magnet-link-list input {'; | |
cssRules += 'width: 100%'; | |
cssRules += '}'; | |
cssRules += '#magnet-link-list, #magnet-link-list * {'; | |
cssRules += 'box-sizing: border-box;'; | |
cssRules += '}'; | |
// Add elements to the document | |
style = document.createElement('style'); | |
style.type = 'text/css'; | |
style.innerHTML = cssRules; | |
document.getElementsByTagName('head')[0].appendChild(style); | |
container.appendChild(linkList); | |
document.body.appendChild(container); | |
}; | |
// Run | |
init(); | |
}()); |
This is a "user script" which is used to modify some web sites to fit personal tastes. You need a browser extension such as TamperMonkey in order to add user scripts to your browser.
This particular user script is meant to find magnet links on web sites (mainly torrent sites) and make them more visible.
Can I share with you what was sent to me and the website that it was taken to? A link was text to me and it sent me to a website that’s private, and I can’t find any information about it, but my research lead me to this specific code thing that I commented on. Is someone trying to hack my phone?Sent from my iPhoneOn Feb 5, 2023, at 5:42 AM, Craig Patik ***@***.***> wrote:Re: ***@***.*** commented on this gist.This is a "user script" which is used to modify some web sites to fit personal tastes. You need a browser extension such as TamperMonkey in order to add user scripts to your browser.This particular user script is meant to find magnet links on web sites (mainly torrent sites) and make them more visible.—Reply to this email directly, view it on GitHub or unsubscribe.You are receiving this email because you commented on the thread.Triage notifications on the go with GitHub Mobile for iOS or Android.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What does this link do specifically? I got a link like this sent to me, idk what it means…