mirror of
https://github.com/MoizAhmedd/youtube-video-search.git
synced 2021-07-26 20:45:06 +03:00
fix mapping on diff links
This commit is contained in:
@@ -16,6 +16,7 @@ An extension that lets you search for words in a youtube video, and seeks to tha
|
||||
- <s>Reset transcript/search on new vids</s>
|
||||
- <s>Switch to indices starting at 1</s>
|
||||
- <s>Option F to toggle search bar off</s>
|
||||
- Test going away from youtube, going to home page etc
|
||||
|
||||
## Development Usage
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
let currVideoID;
|
||||
let mapping;
|
||||
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
|
||||
if ( tab.url && tab.url.includes('watch?v') ) {
|
||||
if(currVideoID != tab.url.split('?v=')[1].slice(0,11)) {
|
||||
@@ -10,21 +11,24 @@ chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
|
||||
})
|
||||
}
|
||||
currVideoID = tab.url.split('?v=')[1].slice(0,11);
|
||||
let endpoint = `http://youtubedl.acceleratedcloudone.com:5000/get-mapping?videoid=${currVideoID}`;
|
||||
// let endpoint = `http://youtubedl.acceleratedcloudone.com:5000/get-mapping?videoid=${currVideoID}`;
|
||||
let endpoint = `http://localhost:5000/get-mapping?videoid=${currVideoID}`;
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", endpoint, true);
|
||||
xhr.onreadystatechange = function () {
|
||||
let resp = ''
|
||||
try {
|
||||
resp = JSON.parse(xhr.responseText);
|
||||
if (resp.mapping) {
|
||||
mapping = resp.mapping;
|
||||
}
|
||||
} catch(error) {
|
||||
console.log('Couldnt parse');
|
||||
}
|
||||
chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
|
||||
if (request.type == "getTimestamp") {
|
||||
console.log(request.word);
|
||||
if (resp.mapping) {
|
||||
sendResponse(resp.mapping[request.word]);
|
||||
if (mapping) {
|
||||
sendResponse(mapping[request.word]);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -34,3 +38,11 @@ chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//Words to search
|
||||
//Elon 1470: Neural
|
||||
//Blaine JRE: breath
|
||||
//Mike Tyson Impaulsive: Boxing
|
||||
Reference in New Issue
Block a user