Last active
October 3, 2019 06:43
-
-
Save ZyqGitHub1/12b3cce8237bb9bfe52b66e7637fe393 to your computer and use it in GitHub Desktop.
Tampermonkey
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== | |
// @run-at document-start | |
// @name:en tumblr Sniffer | |
// @name tumblr 视频嗅探 | |
// @name:zh-CN tumblr 视频嗅探 | |
// @name:zh-TW tumblr 视频嗅探 | |
// @description: tumblr 视频嗅探 | |
// @description:zh-CN: tumblr 视频嗅探 | |
// @description:zh-TW tumblr 视频嗅探 | |
// @description:en tumblr 视频嗅探 | |
// @include https://www.tumblr.com/* | |
// @require https://cdn.bootcss.com/jquery/3.2.1/jquery.js | |
// @version 0.1.7 | |
// 告诉 TamperMonkey 这个脚本不需要转换 | |
// @nocompat Chrome | |
// ==/UserScript== | |
$(document).ready(function () { | |
var funDownload = function (content, filename) { | |
// 创建隐藏的可下载链接 | |
var eleLink = document.createElement('a'); | |
eleLink.download = filename; | |
eleLink.style.display = 'none'; | |
// 字符内容转变成blob地址 | |
var blob = new Blob([content]); | |
eleLink.href = URL.createObjectURL(blob); | |
// 触发点击 | |
document.body.appendChild(eleLink); | |
eleLink.click(); | |
// 然后移除 | |
document.body.removeChild(eleLink); | |
}; | |
var srcList = []; | |
var listDiv = ` | |
<style> | |
#srcList li a:link {color: #FF0000} | |
#srcList li a:visited {color: #00FF00} | |
#srcList li a:hover {color: #FF00FF} | |
#srcList li a:active {color: #0000FF} | |
#srcList { | |
overflow-y:scroll; | |
text-overflow:ellipsis; | |
white-space: nowrap; | |
width: 200px; | |
height: 180px; | |
} | |
#srcPanel { | |
position: fixed; | |
left: 0px; top: 100px; | |
width: 200px; | |
height: 200px; | |
background: white; | |
// overflow-y:scroll; | |
// text-overflow:ellipsis; | |
// white-space: nowrap; | |
} | |
</style> | |
<div id="srcPanel"> | |
<div class="operator"> | |
<button type="button" id="scan">检测</button> | |
<button type="button" id="clear">清除</button> | |
<button type="button" id="save">保存</button> | |
</div> | |
<ol id="srcList"> | |
</ol> | |
</div>`; | |
$('body').append(listDiv); | |
$("#posts").bind('DOMNodeInserted', function (e) { | |
var addSourceSrc = $(e.target).find('source'); | |
if (addSourceSrc.length !== 0) { | |
srcList.push($(addSourceSrc[0]).attr('src')); | |
} | |
}); | |
$('#scan').bind('click', function (e) { | |
$('#srcList').empty(); | |
var srcSet = new Set(srcList); | |
for (let x of Array.from(srcSet)) { | |
$('#srcList').append(`<li><a href=${x} target="_blank">${x}</a></li>`); | |
} | |
}); | |
$('#clear').bind('click', function (e) { | |
$('#srcList').empty(); | |
srcList = []; | |
}); | |
$('#save').bind('click', function (e) { | |
funDownload(JSON.stringify([...new Set(srcList)]), new Date() + '.json'); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment