Skip to content

Commit

Permalink
add todo
Browse files Browse the repository at this point in the history
  • Loading branch information
mkusaka committed May 5, 2023
1 parent 389d037 commit d7192f6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Chrome extension which provides a better slideshare experience
- remove ad in slide
- hide special offer modal
- add `slide={pageNumber}` format suffix & if you reload this page, this page will be shown again.
- TODO: prefetch images?

# chrome store

Expand Down
32 changes: 25 additions & 7 deletions content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,23 +64,39 @@ function proxyClickEventToSlideIFrame(event: Event) {
}

function getSlideNumber() {
// parse slide params
// parse slide params
const urlSearchParams = new URLSearchParams(window.location.search);
const slideNumber = urlSearchParams.get("slide");
if (slideNumber) {
if (slideNumber) {
return parseInt(slideNumber, 10);
}
return null;
}
function setSlideSearchParams(slideNumber: number,withDelete = false) {
// parse slide params
function setSlideSearchParams(slideNumber: number, withDelete = false) {
// parse slide params
const urlSearchParams = new URLSearchParams(window.location.search);
if (withDelete) {
urlSearchParams.delete("slide");
} else {
urlSearchParams.set("slide", slideNumber);
}
return urlSearchParams
return urlSearchParams;
}

const images: HTMLImageElement[] = [];
function prefetchImages() {
const slideImages =
getPropsData()?.props?.pageProps?.slideshow?.slideImages || [];

slideImages.forEach((image) => {
const url = image.baseUrl;
console.log({url})
if (url) {
let img = new Image();
img.src = url;
images.push(img);
}
});
}

const container = document.getElementById("new-player");
Expand Down Expand Up @@ -120,9 +136,10 @@ if (container) {
});
const right = document.querySelector("#right-overlay-rfs");
right?.addEventListener("click", (event) => {
proxyClickEventToSlideIFrame(event)
proxyClickEventToSlideIFrame(event);

const totalSlides = getPropsData()?.props?.pageProps?.slideshow?.totalSlides;
const totalSlides =
getPropsData()?.props?.pageProps?.slideshow?.totalSlides;

if (!totalSlides) {
console.log("cannot find total slides");
Expand All @@ -147,3 +164,4 @@ if (container) {

// hide modal ads as default
Cookies.set("scribd_ad_exit_slideshow_page", true);
// prefetchImages();

0 comments on commit d7192f6

Please sign in to comment.