Skip to content

Minor Tweaks #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file removed src/css/options.css
Empty file.
6 changes: 1 addition & 5 deletions src/html/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<title>SMWC Web Extension</title>
<link rel="icon" href="../images/logo16.png" sizes="any">
<link rel="stylesheet" type="text/css" href="../dist/bootstrap/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="../css/options.css">
<script type="text/javascript" src="../js/theme.js"></script>
</head>
<body>
Expand All @@ -24,10 +23,7 @@ <h1 class="align-middle">SMWC Web Extension</h1>
<caption class="visually-hidden">Keyboard Shortcuts</caption>
<thead class="visually-hidden"><tr><th>Description</th><th>Shortcut</th></tr></thead>
<tbody>
<tr>
<td>Show Popup Action</td>
<td class="text-end"><kbd id="mainKey">Unknown</kbd></td>
</tr>
<tr><td>Show Popup Action</td><td class="text-end"><kbd id="mainKey">Unknown</kbd></td></tr>
</tbody>
</table>
<hr>
Expand Down
4 changes: 2 additions & 2 deletions src/html/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
</div>
<div id="popup-alert" class="alert alert-warning mt-2 visually-hidden" role="alert"></div>
<hr class="my-2">
<form id="options-form">
<form id="options-form" class="mb-2">
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" role="switch" id="contextMenu">
<label class="form-check-label" for="contextMenu">Enable Right Click Menu</label>
Expand All @@ -52,7 +52,7 @@
<label class="form-check-label" for="showUpdate" aria-describedby="showUpdateHelp">Show Release Notes on Update</label>
</div>
</form>
<a class="btn btn-outline-primary btn-sm w-100 mt-3" role="button" data-href="options">
<a class="btn btn-outline-primary btn-sm w-100" role="button" data-href="options">
Open Options
</a>
<hr>
Expand Down
54 changes: 27 additions & 27 deletions src/js/exports.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,32 @@
// JS Exports

/**
* Patch ROM and open URL at key
* TODO: Make Source ROM an Option
* @param {String} url
* @param {String} key
* @param {Function} callback
*/
export function patchRom(url, key, callback) {
const smwcWorld = 'https://smwc.world/patcher/'
const sourceRom =
'https://github.com/videofindersTV/super-mario-world/raw/master/Super.Mario.World.1.smc'
const formdata = new FormData()
formdata.append('patch_url', url)
formdata.append('source_url', sourceRom)

const requestOptions = {
method: 'POST',
body: formdata,
redirect: 'follow',
}

fetch(smwcWorld, requestOptions)
.then((response) => response.json())
.then((result) => callback(result, key))
.catch((error) => console.warn('error', error))
}

/**
* Save Options Callback
* @function saveOptions
Expand Down Expand Up @@ -39,30 +66,3 @@ export function updateOptions(options) {
}
}
}

/**
* Patch ROM and open URL at key
* TODO: Make Source ROM an Option
* @param {String} url
* @param {String} key
* @param {Function} callback
*/
export function patchRom(url, key, callback) {
const smwcWorld = 'https://smwc.world/patcher/'
const sourceRom =
'https://github.com/videofindersTV/super-mario-world/raw/master/Super.Mario.World.1.smc'
const formdata = new FormData()
formdata.append('patch_url', url)
formdata.append('source_url', sourceRom)

const requestOptions = {
method: 'POST',
body: formdata,
redirect: 'follow',
}

fetch(smwcWorld, requestOptions)
.then((response) => response.json())
.then((result) => callback(result, key))
.catch((error) => console.warn('error', error))
}
2 changes: 1 addition & 1 deletion src/js/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ async function popupLinks(event) {
*/
async function updateSearchType(event) {
console.log('updateSearchType:', event)
let { popup } = await chrome.storage.sync.get(['popup'])
const { popup } = await chrome.storage.sync.get(['popup'])
popup.searchType = event.target.id
await chrome.storage.sync.set({ popup })
const value = document.getElementById('patch-input').value
Expand Down
2 changes: 1 addition & 1 deletion src/js/service-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ async function onInstalled(details) {
if (manifest.version !== details.previousVersion) {
const url = `${githubURL}/releases/tag/${manifest.version}`
console.log(`url: ${url}`)
await chrome.tabs.create({ active: true, url })
await chrome.tabs.create({ active: false, url })
}
}
}
Expand Down