Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Leenshady authored Mar 3, 2021
1 parent b34ba84 commit 3d81a92
Show file tree
Hide file tree
Showing 12 changed files with 133 additions and 0 deletions.
16 changes: 16 additions & 0 deletions m3u8Sniffer/background.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>background</title>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/background.js"></script>
</head>
<body style="width:300px;min-height:150px;">
<h3>m3u8Sniffer</h3>
<div id="box" class="box" style="width:250px;min-height:100px;margin:20px auto;padding: 15px;border:gray solid 1px;">
<div style="width: 250px;margin-top: 5px;"><span style="width: 200px;">main.m3u8</span><a href="#" style="float: right;">复制</a></div>
<div style="width: 250px;margin-top: 5px;"><span style="width: 200px;">main.m3u8</span><a href="#" style="float: right;">复制</a></div>
</div>
</body>
</html>
Binary file added m3u8Sniffer/img/icon_128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added m3u8Sniffer/img/icon_16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added m3u8Sniffer/img/icon_19.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added m3u8Sniffer/img/icon_32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added m3u8Sniffer/img/icon_48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions m3u8Sniffer/js/background.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
var m3u8list=[];
var filename=[];
var tabs={};
var pattern = /http[s]?[://]{1}[-A-Za-z0-9+&@#/%?=~_|!:,.;]*[-A-Za-z0-9+&@#/%=~_|]*.m3u8$/
chrome.webRequest.onBeforeSendHeaders.addListener(details => {
var tmp;
if(/\?/.test(details.url)){
tmp = details.url.slice(0,details.url.indexOf("?"));
}else{
tmp = details.url;
}
//console.log(details.url);
//console.log(tmp);
if(pattern.test(tmp)){
console.log(details.tabId);
if(!(details.tabId in tabs)){
tabs[details.tabId] ={};
tabs[details.tabId].m3u8list=[];
tabs[details.tabId].filename=[];
}
tabs[details.tabId].m3u8list.push(details.url);
tabs[details.tabId].filename.push(tmp.slice(tmp.lastIndexOf("/")+1,tmp.length));
}
}, {urls: ["<all_urls>"]},["requestHeaders"]);
25 changes: 25 additions & 0 deletions m3u8Sniffer/js/content-script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
var m3u8list=[];
var filename=[];
var pattern = /http[s]?[://]{1}[-A-Za-z0-9+&@#/%?=~_|!:,.;]*[-A-Za-z0-9+&@#/%=~_|]*.m3u8$/
chrome.webRequest.onBeforeRequest.addListener(details => {
var tmp;
if(/\?/.test(details.url)){
tmp = details.url.slice(0,details.url.indexOf("?"));
}else{
tmp = details.url;
}
//console.log(details.url);
//console.log(tmp);
if(pattern.test(tmp)){
m3u8list.push(details.url);
filename.push(tmp.slice(tmp.lastIndexOf("/")+1,tmp.length));
}
}, {urls: ["<all_urls>"]},["extraHeaders"]);

chrome.runtime.onMessage.addListener(function(request, sender, sendResponse)
{
if(request.cmd == 'm3u8' && request.value == 'popup'){
var resp = {m3u8list:m3u8list,filename:filename};
sendResponse(resp);
}
});
2 changes: 2 additions & 0 deletions m3u8Sniffer/js/jquery.min.js

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions m3u8Sniffer/js/popup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
var tabID;
$(function(){
var bg = chrome.extension.getBackgroundPage();
chrome.tabs.getSelected(null, function (tab) { // 先获取当前页面的tabID
tabID = tab.id;
console.log(tabID)
for(i=0;i<bg.tabs[tabID].filename.length;i++){
$("#box").append('<div id=url'+i+' style="width: 250px;margin-top: 5px;"><span style="width: 200px;">'+bg.tabs[tabID].filename[i]+'</span><a href="#" style="float: right;">复制</a></div>');
$("#url"+i).click({"url":bg.tabs[tabID].m3u8list[i]},copyUrl);
}
});
})

function copyUrl(obj){
var oInput = document.createElement('input');
oInput.value = obj.data.url;
document.body.appendChild(oInput);
oInput.select(); // 选择对象
document.execCommand("Copy"); // 执行浏览器复制命令
oInput.className = 'oInput';
oInput.style.display='none';
alert('复制成功');
}
28 changes: 28 additions & 0 deletions m3u8Sniffer/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"manifest_version": 2,
"name": "m3u8Sniffer",
"version": "1.0.0",
"description": "m3u8嗅探器,可以列出页面的m3u8文件",
"icons":
{
"16": "img/icon_16.png",
"48": "img/icon_48.png",
"128": "img/icon_128.png"
},
"browser_action":
{
"default_icon": "img/icon_19.png",
"default_popup": "popup.html"
},
"permissions":
[
"webRequest",
"tabs",
"http://*/*",
"https://*/*"
],
"background":
{
"page": "background.html"
}
}
15 changes: 15 additions & 0 deletions m3u8Sniffer/popup.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>m3u8Sniffer</title>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/popup.js"></script>
</head>
<body style="width:300px;min-height:150px;">
<h3>m3u8Sniffer</h3>
<div id="box" class="box" style="width:250px;min-height:100px;margin:20px auto;padding: 15px;border:gray solid 1px;">

</div>
</body>
</html>

0 comments on commit 3d81a92

Please sign in to comment.