Skip to content

Commit

Permalink
Merge pull request #548 from d-i-t-a/develop
Browse files Browse the repository at this point in the history
added scramble exclusion list to config
  • Loading branch information
aferditamuriqi authored Sep 22, 2023
2 parents d3ad1e2 + 48f01fe commit a8b0075
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 8 deletions.
10 changes: 8 additions & 2 deletions src/modules/protection/ContentProtectionModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export interface ContentProtectionModuleProperties {
hideTargetUrl: boolean;
disableDrag: boolean;
supportedBrowsers: string[];
excludeNodes: string[];
}

export interface ContentProtectionModuleConfig
Expand Down Expand Up @@ -1373,8 +1374,13 @@ export class ContentProtectionModule implements ReaderModule {
return textNodes.map((node) => {
const { top, height, left, width } = this.measureTextNode(node);
const scrambled =
node.parentElement?.nodeName === "option" ||
node.parentElement?.nodeName === "script"
node.parentElement &&
((this.properties?.excludeNodes &&
this.properties?.excludeNodes.indexOf(
node.parentElement.nodeName.toLowerCase()
) > -1) ||
node.parentElement?.nodeName.toLowerCase() === "option" ||
node.parentElement?.nodeName.toLowerCase() === "script")
? node.textContent
: this.obfuscateText(node.textContent ?? "");
let rect: ContentProtectionRect = {
Expand Down
2 changes: 1 addition & 1 deletion src/modules/sampleread/SampleReadEventHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export default class SampleReadEventHandler {
this.navigator.errorMessage.style.backgroundColor =
"rgb(255, 255, 255)";
this.navigator.errorMessage.innerHTML =
this.navigator.sample?.popup ?? "";
"<span>" + this.navigator.sample?.popup + "</span>" ?? "";
}
} else {
this.navigator.iframes[0].focus();
Expand Down
8 changes: 5 additions & 3 deletions src/styles/sass/reader/_error.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@
*/

.error {
position: relative;
position: sticky;
z-index: 20;
background-color: transparentize($ui-white, 0.125);
color: $error-red;
height: 100%;
top: 0;
padding-top: 40vh;
text-align: center;
width: 100%;
-webkit-user-select: none;
Expand All @@ -42,9 +41,12 @@
}

span {
display: block;
display: flex;
margin-bottom: 0.75rem;
font-size: 1.2rem;
height: 100vh;
justify-content: center;
align-items: center;
}

button {
Expand Down
2 changes: 1 addition & 1 deletion src/styles/sass/reader/_loading.scss
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
}

.loading {
position: sticky;
position: absolute;
width: 100%;
height: 100%;
top: 0;
Expand Down
3 changes: 2 additions & 1 deletion viewer/index_dita.html
Original file line number Diff line number Diff line change
Expand Up @@ -1310,6 +1310,7 @@
disableContextMenu: true,
hideTargetUrl: true,
disableDrag: false,
excludeNodes:["script", "option"],
supportedBrowsers: [ // this will only be used if enforceSupportedBrowsers is true, and has nothing to do with the r2d2bc modules supported browsers
"Chrome", "ChromeAndroid", "Edge", "Firefox", "iOS", "Safari",
],
Expand Down Expand Up @@ -1405,7 +1406,7 @@

}).catch(error => {
console.error(error);
document.getElementById("reader-error").innerText = error.message;
document.getElementById("reader-error").innerHTML = "<span>"+error.message +"</span>";
});

function setColumns(columnCount) {
Expand Down

0 comments on commit a8b0075

Please sign in to comment.