diff --git a/background.js b/background.js index 83829dc..26f0dc0 100644 --- a/background.js +++ b/background.js @@ -59,6 +59,9 @@ var Handlers = [{ }, { execScript: 'savethevideo-com.js', urls: ['https://vimeo.com/'], +}, { + execScript: 'snapany-com.js', + urls: ['www.bilibili.com/video/'], }, { execScript: 'cookie.js', urls: ['weibo.com'], @@ -73,7 +76,9 @@ chrome.browserAction.onClicked.addListener(function(tab) { for (var j = 0; j < h.urls.length; j++) { var url = h.urls[j]; if (tab.url.indexOf(url) > -1) { - chrome.tabs.executeScript({file: h.execScript}); + chrome.tabs.executeScript(null, {file: "util.js"}, function() { + chrome.tabs.executeScript(null, {file: h.execScript}); + }); return } } diff --git a/cookie.js b/cookie.js index ac05f7b..5d2cc0f 100644 --- a/cookie.js +++ b/cookie.js @@ -1,16 +1,2 @@ -copyToClipboard = str => { - console.log("copyToClipboard"); - const el = document.createElement('textarea'); - el.value = str; - el.setAttribute('readonly', ''); - el.style.position = 'absolute'; - el.style.left = '-9999px'; - document.body.appendChild(el); - el.select(); - document.execCommand('copy'); - document.body.removeChild(el); -}; - alert("已复制 Cookie:" + document.cookie); - copyToClipboard(document.cookie) diff --git a/snapany-com.js b/snapany-com.js new file mode 100644 index 0000000..cef1498 --- /dev/null +++ b/snapany-com.js @@ -0,0 +1,4 @@ +copyToClipboard(window.location.href) +var target = 'https://snapany.com/zh/bilibili' +alert('已复制视频地址到剪贴板,跳转到' + target + '开始下载') +window.open(target) diff --git a/util.js b/util.js new file mode 100644 index 0000000..d375c9f --- /dev/null +++ b/util.js @@ -0,0 +1,12 @@ +copyToClipboard = str => { + console.log("copyToClipboard"); + const el = document.createElement('textarea'); + el.value = str; + el.setAttribute('readonly', ''); + el.style.position = 'absolute'; + el.style.left = '-9999px'; + document.body.appendChild(el); + el.select(); + document.execCommand('copy'); + document.body.removeChild(el); +};