Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
moana16 committed Apr 13, 2023
2 parents 44f4e98 + 314e4e4 commit de15f34
Showing 1 changed file with 27 additions and 21 deletions.
48 changes: 27 additions & 21 deletions src/content/index.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,33 @@
console.info('chrome-ext template-react-ts content script');

console.info('pop-filterbubble-client content script');
const root = document.documentElement;
let videoList = root.querySelectorAll('#video-title-link');
let LinktoArr = Array.from(videoList);
LinktoArr.map((a,idx) => {
if (a instanceof HTMLAnchorElement) {
let href = a.href;
let params = href .substring( href .indexOf('=')+1, href .length );
console.log(idx, params);
let originLength = 0;
setInterval(() => {
const videoList = root.querySelectorAll('#text > a');
const linkToArr = Array.from(videoList);
let updateLength = 0;
if (originLength === 0) {
//만약 아예 받아온 데이터가 없으면!
updateLength = getChannelIdList(linkToArr);
} else if (linkToArr.length > originLength) {
//새로운 값이 들어올 때
linkToArr.splice(0, originLength); //중복되는 값은 제거
updateLength = getChannelIdList(linkToArr);
}
});

//개수가 24개 이하면 처리
originLength += updateLength;
}, 5000);

/*function getVideoId () {
for(let i :number = 0; i < videoList.length; i++) {
if (videoList[i] instanceof HTMLAnchorElement) {
let href = videoList[i].href;
}
function getChannelIdList(linkToArr: Array<Element>): number {
const newVideoList = linkToArr.map((a, idx) => {
if (a instanceof HTMLAnchorElement) {
const href = a.href;
const channelId = href.split('/').reverse()[0];
return channelId;
}
};
console.log(root.innerHTML);*/
});
let updateLength = newVideoList.length;
console.log(newVideoList);
//여기서 서버에 전송하는 코드넣으면 될 듯?
return updateLength;
}

export {};

0 comments on commit de15f34

Please sign in to comment.