Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// TypeScript doesn't merge the definitions so `...` is not equivalent.
// eslint-disable-next-line prefer-object-spread
const defaults = Object.assign({
customCSS: '',
personalToken: '',
logging: false,
minimizedUsers: ''
}, __featuresOptionDefaults__); // This variable is replaced at build time
const migrations = [
featureWasRenamed('filter-pr-by-build-status', 'pr-filters'), // Merged on November 1st
featureWasRenamed('linkify-branch-refs', 'linkify-branch-references'), // Merged on November 10th
featureWasRenamed('prev-next-commit-buttons', 'previous-next-commit-buttons'), // Merged on November 10th
// Removed features will be automatically removed from the options as well
OptionsSync.migrations.removeUnused
];
// Keep this function "dumb". Don't move more "smart" domain selection logic in here
function getStorageName(host: string): string {
if (/(^|\.)github\.com$/.test(host)) {
return 'options';
}
return `options-${host}`;
}
function getOptions(host: string): OptionsSync {
return new OptionsSync({storageName: getStorageName(host), migrations, defaults});
}
// This should return the options for the current domain or, if called from an extension page, for `github.com`
import OptionsSync from 'webext-options-sync';
import {featuresDefaultValues} from './features';
const optionsSync = new OptionsSync();
// Define defaults
optionsSync.define({
defaults: Object.assign({}, featuresDefaultValues, {
logging: false
}),
migrations: [
OptionsSync.migrations.removeUnused
]
});
// Make sure that all features have an option value
optionsSync.getAll().then(options => {
const newOptions = Object.assign({}, featuresDefaultValues, options);
optionsSync.setAll(newOptions);
});
// Fix the extension when right-click saving a tweet image
browser.downloads.onDeterminingFilename.addListener((item, suggest) => {
suggest({
filename: item.filename.replace(/\.(jpg|png)_(large|orig)$/, '.$1')
});
});
},
migrations: [
options => {
options.disabledFeatures = options.disabledFeatures.replace('toggle-all-things-with-alt', ''); // #1524
options.disabledFeatures = options.disabledFeatures.replace('remove-diff-signs', ''); // #1524
options.disabledFeatures = options.disabledFeatures.replace('add-confirmation-to-comment-cancellation', ''); // #1524
options.disabledFeatures = options.disabledFeatures.replace('add-your-repositories-link-to-profile-dropdown', ''); // #1460
options.disabledFeatures = options.disabledFeatures.replace('add-readme-buttons', 'hide-readme-header'); // #1465
options.disabledFeatures = options.disabledFeatures.replace('add-delete-to-pr-files', ''); // #1462
options.disabledFeatures = options.disabledFeatures.replace('auto-load-more-news', 'infinite-scroll'); // #1516
options.disabledFeatures = options.disabledFeatures.replace('display-issue-suggestions', ''); // #1611
options.disabledFeatures = options.disabledFeatures.replace('open-all-selected', 'batch-open-issues'); // #1402
options.disabledFeatures = options.disabledFeatures.replace('copy-file-path', ''); // #1628
options.disabledFeatures = options.disabledFeatures.replace('hide-issue-list-autocomplete', ''); // #1657
},
OptionsSync.migrations.removeUnused
]
});
browser.runtime.onMessage.addListener(async message => {
if (!message || message.action !== 'openAllInTabs') {
return;
}
const [currentTab] = await browser.tabs.query({currentWindow: true, active: true});
for (const [i, url] of message.urls.entries()) {
browser.tabs.create({
url,
index: currentTab.index + i + 1,
active: false
});
}
});
) {
savedOptions.matchRoomAutoVetoMapItems = savedOptions.matchRoomAutoVetoMapItems.filter(
map => map !== 'de_cbble'
)
savedOptions.matchRoomAutoVetoMapItems.push('de_vertigo')
}
if (savedOptions.bans) {
delete savedOptions.bans
}
if (savedOptions.vips) {
delete savedOptions.vips
}
},
OptionsSync.migrations.removeUnused
]
})
browser.runtime.onMessage.addListener(async message => {
if (!message) {
return
}
switch (message.action) {
case 'notification': {
const { name } = browser.runtime.getManifest()
delete message.action
browser.notifications.create('', {
type: 'basic',
...message,
import OptionsSync from 'webext-options-sync';
export default new OptionsSync({
defaults: {
colorRed: 244,
colorGreen: 67,
colorBlue: 54
},
migrations: [
OptionsSync.migrations.removeUnused
],
logging: true
});
import OptionsSync from 'webext-options-sync';
const optionsStorage = new OptionsSync({
defaults: {
token: '',
rootUrl: 'https://api.github.com/',
playNotifSound: false,
showDesktopNotif: false,
onlyParticipating: false,
reuseTabs: false,
updateCountOnNavigation: false
},
migrations: [
OptionsSync.migrations.removeUnused
]
});
export default optionsStorage;
if (savedOptions.hideTags) {
savedOptions.tags = 'hide';
}
if (savedOptions.hideCommits) {
savedOptions.commits = 'hide';
}
if (savedOptions.hideClosedIssues) {
savedOptions.closedIssues = 'hide';
}
delete savedOptions.hideCollaborators;
delete savedOptions.hideBranches;
delete savedOptions.hideTags;
delete savedOptions.hideCommits;
delete savedOptions.hideClosedIssues;
},
OptSync.migrations.removeUnused
],
});
lineLengthLimitEnabled: true,
lineLengthLimit: 80,
customStyles: '',
enableUpdateNotifications: true,
stickyHeader: true,
},
migrations: [
async savedOptions => {
if (savedOptions.enableUpdateNotifications) {
await justInstalledOrUpdated
window.open(
'https://github.com/refined-bitbucket/refined-bitbucket/releases/latest'
)
}
},
OptionsSync.migrations.removeUnused,
],
})