Skip to content

Commit

Permalink
Run prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
SinclaM committed Jul 23, 2022
1 parent 0b28cd2 commit 1ab5328
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 100 deletions.
62 changes: 29 additions & 33 deletions src/background/chrome/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ chrome.webRequest.onBeforeRedirect.addListener(
// is gone.
try {
// tsserver says await has no effect on the expression below but it's
// actually critical to resolve the returned promise and catch the error.
// It looks like the type definition from @types/chrome is not up to date
// actually critical to resolve the returned promise and catch the error.
// It looks like the type definition from @types/chrome is not up to date
// with the manifest v3 promise behavior for this funciton.
await chrome.tabs.sendMessage(tabId, { message: "redirect-detected" });
break;
Expand All @@ -38,40 +38,36 @@ chrome.webRequest.onBeforeRedirect.addListener(
chrome.storage.onChanged.addListener((changes) => {
if (typeof changes.enableMathquillOverrides !== "undefined") {
if (changes.enableMathquillOverrides.newValue) {
chrome.declarativeNetRequest.updateDynamicRules(
{
addRules: [
{
id: 1,
priority: 1,
action: {
type: chrome.declarativeNetRequest.RuleActionType.REDIRECT,
redirect: { extensionPath: "/empty.js" },
},
condition: {
urlFilter: "https://www.desmos.com/assets/build/calculator_desktop-*.js|",
},
chrome.declarativeNetRequest.updateDynamicRules({
addRules: [
{
id: 1,
priority: 1,
action: {
type: chrome.declarativeNetRequest.RuleActionType.REDIRECT,
redirect: { extensionPath: "/empty.js" },
},
{
id: 2,
priority: 2,
action: {
type: chrome.declarativeNetRequest.RuleActionType.REDIRECT,
redirect: { extensionPath: "/empty.js" },
},
condition: {
urlFilter: "https://www.desmos.com/assets/build/calculator_desktop-*.js?|",
},
condition: {
urlFilter: "https://www.desmos.com/assets/build/calculator_desktop-*.js|",
},
],
}
);
},
{
id: 2,
priority: 2,
action: {
type: chrome.declarativeNetRequest.RuleActionType.REDIRECT,
redirect: { extensionPath: "/empty.js" },
},
condition: {
urlFilter: "https://www.desmos.com/assets/build/calculator_desktop-*.js?|",
},
},
],
});
} else {
chrome.declarativeNetRequest.updateDynamicRules(
{
removeRuleIds: [1, 2],
}
);
chrome.declarativeNetRequest.updateDynamicRules({
removeRuleIds: [1, 2],
});
}
}
});
62 changes: 29 additions & 33 deletions src/background/edge/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ chrome.webRequest.onBeforeRedirect.addListener(
// is gone.
try {
// tsserver says await has no effect on the expression below but it's
// actually critical to resolve the returned promise and catch the error.
// It looks like the type definition from @types/chrome is not up to date
// actually critical to resolve the returned promise and catch the error.
// It looks like the type definition from @types/chrome is not up to date
// with the manifest v3 promise behavior for this funciton.
await chrome.tabs.sendMessage(tabId, { message: "redirect-detected" });
break;
Expand All @@ -38,40 +38,36 @@ chrome.webRequest.onBeforeRedirect.addListener(
chrome.storage.onChanged.addListener((changes) => {
if (typeof changes.enableMathquillOverrides !== "undefined") {
if (changes.enableMathquillOverrides.newValue) {
chrome.declarativeNetRequest.updateDynamicRules(
{
addRules: [
{
id: 1,
priority: 1,
action: {
type: chrome.declarativeNetRequest.RuleActionType.REDIRECT,
redirect: { extensionPath: "/empty.js" },
},
condition: {
urlFilter: "https://www.desmos.com/assets/build/calculator_desktop-*.js|",
},
chrome.declarativeNetRequest.updateDynamicRules({
addRules: [
{
id: 1,
priority: 1,
action: {
type: chrome.declarativeNetRequest.RuleActionType.REDIRECT,
redirect: { extensionPath: "/empty.js" },
},
{
id: 2,
priority: 2,
action: {
type: chrome.declarativeNetRequest.RuleActionType.REDIRECT,
redirect: { extensionPath: "/empty.js" },
},
condition: {
urlFilter: "https://www.desmos.com/assets/build/calculator_desktop-*.js?|",
},
condition: {
urlFilter: "https://www.desmos.com/assets/build/calculator_desktop-*.js|",
},
],
}
);
},
{
id: 2,
priority: 2,
action: {
type: chrome.declarativeNetRequest.RuleActionType.REDIRECT,
redirect: { extensionPath: "/empty.js" },
},
condition: {
urlFilter: "https://www.desmos.com/assets/build/calculator_desktop-*.js?|",
},
},
],
});
} else {
chrome.declarativeNetRequest.updateDynamicRules(
{
removeRuleIds: [1, 2],
}
);
chrome.declarativeNetRequest.updateDynamicRules({
removeRuleIds: [1, 2],
});
}
}
});
62 changes: 29 additions & 33 deletions src/background/opera/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ chrome.webRequest.onBeforeRedirect.addListener(
// is gone.
try {
// tsserver says await has no effect on the expression below but it's
// actually critical to resolve the returned promise and catch the error.
// It looks like the type definition from @types/chrome is not up to date
// actually critical to resolve the returned promise and catch the error.
// It looks like the type definition from @types/chrome is not up to date
// with the manifest v3 promise behavior for this funciton.
await chrome.tabs.sendMessage(tabId, { message: "redirect-detected" });
break;
Expand All @@ -38,40 +38,36 @@ chrome.webRequest.onBeforeRedirect.addListener(
chrome.storage.onChanged.addListener((changes) => {
if (typeof changes.enableMathquillOverrides !== "undefined") {
if (changes.enableMathquillOverrides.newValue) {
chrome.declarativeNetRequest.updateDynamicRules(
{
addRules: [
{
id: 1,
priority: 1,
action: {
type: chrome.declarativeNetRequest.RuleActionType.REDIRECT,
redirect: { extensionPath: "/empty.js" },
},
condition: {
urlFilter: "https://www.desmos.com/assets/build/calculator_desktop-*.js|",
},
chrome.declarativeNetRequest.updateDynamicRules({
addRules: [
{
id: 1,
priority: 1,
action: {
type: chrome.declarativeNetRequest.RuleActionType.REDIRECT,
redirect: { extensionPath: "/empty.js" },
},
{
id: 2,
priority: 2,
action: {
type: chrome.declarativeNetRequest.RuleActionType.REDIRECT,
redirect: { extensionPath: "/empty.js" },
},
condition: {
urlFilter: "https://www.desmos.com/assets/build/calculator_desktop-*.js?|",
},
condition: {
urlFilter: "https://www.desmos.com/assets/build/calculator_desktop-*.js|",
},
],
}
);
},
{
id: 2,
priority: 2,
action: {
type: chrome.declarativeNetRequest.RuleActionType.REDIRECT,
redirect: { extensionPath: "/empty.js" },
},
condition: {
urlFilter: "https://www.desmos.com/assets/build/calculator_desktop-*.js?|",
},
},
],
});
} else {
chrome.declarativeNetRequest.updateDynamicRules(
{
removeRuleIds: [1, 2],
}
);
chrome.declarativeNetRequest.updateDynamicRules({
removeRuleIds: [1, 2],
});
}
}
});
5 changes: 4 additions & 1 deletion src/script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,8 @@ function getAutoOperators() {
// | and more verbose breakdown of the function. For example, in this string might be
// ln|natural-log. The regex filters out the verbose parts and keeps just the function
// names.
return window.require("main/mathquill-operators").getAutoOperators().replace(/\|[^ ]*/g, "");
return window
.require("main/mathquill-operators")
.getAutoOperators()
.replace(/\|[^ ]*/g, "");
}

0 comments on commit 1ab5328

Please sign in to comment.