Fix inaccessible file message. Closes #574 (#575)

* Fix inaccessible file message. Closes #574

* Reword inaccessible message
This commit is contained in:
Rob Garrison 2018-11-24 06:03:01 -06:00 committed by GitHub
parent 05ec2fb1c7
commit 764fe399f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 4 deletions

View File

@ -1373,6 +1373,10 @@
"message": "Stylus can access file:// URLs only if you enable the corresponding checkbox for Stylus extension on chrome://extensions page.", "message": "Stylus can access file:// URLs only if you enable the corresponding checkbox for Stylus extension on chrome://extensions page.",
"description": "Note in the toolbar popup for file:// URLs" "description": "Note in the toolbar popup for file:// URLs"
}, },
"InaccessibleFileHint": {
"message": "Stylus can not access some file types (e.g. pdf & json files).",
"description": "Note in the toolbar popup for some file types that cannot be accessed"
},
"updateAllCheckSucceededNoUpdate": { "updateAllCheckSucceededNoUpdate": {
"message": "No updates found.", "message": "No updates found.",
"description": "Text that displays when an update all check completed and no updates are available" "description": "Text that displays when an update all check completed and no updates are available"

View File

@ -80,7 +80,6 @@
<template data-id="unreachableInfo"> <template data-id="unreachableInfo">
<div class="blocked-info"> <div class="blocked-info">
<label i18n-text="unreachableContentScript"></label> <label i18n-text="unreachableContentScript"></label>
<p i18n-text="unreachableFileHint"></p>
</div> </div>
</template> </template>

View File

@ -130,6 +130,10 @@ function initPopup() {
return; return;
} }
const info = template.unreachableInfo; const info = template.unreachableInfo;
if (!FIREFOX) {
// Chrome "Allow access to file URLs" in chrome://extensions message
info.appendChild($create('p', t('unreachableFileHint')));
}
if (FIREFOX && tabURL.startsWith(URLS.browserWebStore)) { if (FIREFOX && tabURL.startsWith(URLS.browserWebStore)) {
$('label', info).textContent = t('unreachableAMO'); $('label', info).textContent = t('unreachableAMO');
const note = (FIREFOX < 59 ? t('unreachableAMOHintOldFF') : t('unreachableAMOHint')) + const note = (FIREFOX < 59 ? t('unreachableAMOHintOldFF') : t('unreachableAMOHint')) +
@ -137,9 +141,11 @@ function initPopup() {
const renderToken = s => s[0] === '<' ? $create('b', tWordBreak(s.slice(1, -1))) : s; const renderToken = s => s[0] === '<' ? $create('b', tWordBreak(s.slice(1, -1))) : s;
const renderLine = line => $create('p', line.split(/(<.*?>)/).map(renderToken)); const renderLine = line => $create('p', line.split(/(<.*?>)/).map(renderToken));
const noteNode = $create('fragment', note.split('\n').map(renderLine)); const noteNode = $create('fragment', note.split('\n').map(renderLine));
const target = $('p', info); info.appendChild(noteNode);
target.parentNode.insertBefore(noteNode, target); }
target.remove(); // Inaccessible locally hosted file type, e.g. JSON, PDF, etc.
if (tabURL.length - tabURL.lastIndexOf(".") <= 5) {
info.appendChild($create('p', t('InaccessibleFileHint')));
} }
document.body.classList.add('unreachable'); document.body.classList.add('unreachable');
document.body.insertBefore(info, document.body.firstChild); document.body.insertBefore(info, document.body.firstChild);