42 lines
1.3 KiB
HTML
42 lines
1.3 KiB
HTML
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
|
|
<script type="text/javascript">
|
|
|
|
function post(url, data, callack){
|
|
$.ajax({
|
|
url: url,
|
|
type: 'POST',
|
|
data: JSON.stringify(data),
|
|
contentType: "application/json; charset=utf-8",
|
|
dataType: "json",
|
|
complete: function(res, text){
|
|
callack(
|
|
text !== 'success' ? res.statusText : null,
|
|
JSON.parse(res.responseText),
|
|
res.status
|
|
)
|
|
}
|
|
});
|
|
}
|
|
|
|
$( document ).ready(function() {
|
|
|
|
$('a').each(function(idx, el){
|
|
var $el = $(el);
|
|
if($el.attr('href') && $el.attr('href').match("magnet:?")){
|
|
$el.before('<img class="718link" src="https://chocolatey.org/content/packageimages/transmission.2.92.svg" height=24 width=24 data-link="'+$el.attr('href')+'"/>')
|
|
}
|
|
})
|
|
|
|
$("body").on('click', 'img.718link', function(el){
|
|
|
|
post('/__api/torrent', {
|
|
magnet: window.btoa($(this).data('link')),
|
|
password: prompt('password?')
|
|
}, function(err, data){
|
|
console.log(arguments);
|
|
});
|
|
|
|
});
|
|
});
|
|
|
|
</script> |