merged new checkbox for bookmarklet: enables ability to set bookmarklet to audio only

fixed two bugs for audio only files: sometimes downloads failed as extensions were improperly removed and readded, removing a single character from the filename.

Fixed another extension-related bug where metadata from deleted audio files persisted
This commit is contained in:
Isaac Grynsztein
2020-04-05 15:19:12 -04:00
parent 1d9595d056
commit 7ef6c78612
4 changed files with 36 additions and 9 deletions

View File

@@ -7,6 +7,7 @@ import {DomSanitizer} from '@angular/platform-browser';
import { MatDialog } from '@angular/material/dialog';
import { ArgModifierDialogComponent } from 'app/dialogs/arg-modifier-dialog/arg-modifier-dialog.component';
import { CURRENT_VERSION } from 'app/consts';
import { MatCheckboxChange } from '@angular/material/checkbox';
@Component({
selector: 'app-settings',
@@ -22,6 +23,7 @@ export class SettingsComponent implements OnInit {
new_config = null
loading_config = false;
generated_bookmarklet_code = null;
bookmarkletAudioOnly = false;
_settingsSame = true;
@@ -96,11 +98,17 @@ export class SettingsComponent implements OnInit {
generateBookmarkletCode() {
const currentURL = window.location.href.split('#')[0];
const homePageWithArgsURL = currentURL + '#/home;url=';
const bookmarkletCodeInside = `'${homePageWithArgsURL}' + window.location`
const bookmarkletCode = `javascript:(function()%7Bwindow.open('${homePageWithArgsURL}' + encodeURIComponent(window.location))%7D)()`;
const audioOnly = this.bookmarkletAudioOnly;
// tslint:disable-next-line: max-line-length
const bookmarkletCode = `javascript:(function()%7Bwindow.open('${homePageWithArgsURL}' + encodeURIComponent(window.location) + ';audioOnly=${audioOnly}')%7D)()`;
return bookmarkletCode;
}
bookmarkletAudioOnlyChanged(event: MatCheckboxChange): void {
this.bookmarkletAudioOnly = event.checked;
this.generated_bookmarklet_code = this.sanitizer.bypassSecurityTrustUrl(this.generateBookmarkletCode());
}
// not currently functioning on most platforms. hence not in use
bookmarksite(title, url) {
// Internet Explorer