fix mapping on diff links

This commit is contained in:
MoizAhmedd
2021-03-16 17:31:10 -04:00
parent 3afff3a21f
commit 98e55de0ce
2 changed files with 17 additions and 4 deletions

View File

@@ -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

View File

@@ -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