Skip to content

Commit

Permalink
support bilibili video download
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhuPeng committed May 11, 2024
1 parent 11bb531 commit 9da5424
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 15 deletions.
7 changes: 6 additions & 1 deletion background.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand All @@ -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
}
}
Expand Down
14 changes: 0 additions & 14 deletions cookie.js
Original file line number Diff line number Diff line change
@@ -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)
4 changes: 4 additions & 0 deletions snapany-com.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
copyToClipboard(window.location.href)
var target = 'https://snapany.com/zh/bilibili'
alert('已复制视频地址到剪贴板,跳转到' + target + '开始下载')
window.open(target)
12 changes: 12 additions & 0 deletions util.js
Original file line number Diff line number Diff line change
@@ -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);
};

0 comments on commit 9da5424

Please sign in to comment.