Skip to content

Commit ba4d8f8

Browse files
committed
Revert "Merge branch 'firefox' into develop"
This reverts commit f812cd1, reversing changes made to 962dc6e.
1 parent f812cd1 commit ba4d8f8

File tree

13 files changed

+45
-54
lines changed

13 files changed

+45
-54
lines changed

background/background.js

+11-11
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
} from '../constants/functions.js'
1212

1313
// handle install
14-
browser.runtime.onInstalled.addListener((details) => {
14+
chrome.runtime.onInstalled.addListener((details) => {
1515
if (details.reason == 'install') {
1616
// check is extension already in use at other device
1717
storageGet(['thisWebsiteWork', 'thisWebsiteWorkEasy'], (response) => {
@@ -32,11 +32,11 @@ browser.runtime.onInstalled.addListener((details) => {
3232
restoreCont: false
3333
})
3434

35-
browser.tabs.create({url: 'https://romanisthere.github.io/PopUpOFF-Website/index.html#greetings-firefox'})
35+
chrome.tabs.create({url: 'https://romanisthere.github.io/PopUpOFF-Website/index.html#greetings-chrome'})
3636
}
3737
})
3838
} else if (details.reason == 'update') {
39-
browser.tabs.create({url: 'https://romanisthere.github.io/apps/popupoff/updates/#1.1.7'})
39+
chrome.tabs.create({url: 'https://romanisthere.github.io/apps/popupoff/updates/#1.1.7'})
4040
storageGet('stats', (resp) => {
4141
let fixedStats = {}
4242
if (!resp.stats) {
@@ -62,23 +62,23 @@ browser.runtime.onInstalled.addListener((details) => {
6262
})
6363

6464
// handle tab switch(focus)
65-
browser.tabs.onActivated.addListener((activeInfo) => {
66-
browser.tabs.query({ 'active': true }, (info) => {
65+
chrome.tabs.onActivated.addListener((activeInfo) => {
66+
chrome.tabs.query({ 'active': true }, (info) => {
6767
const url = info[0].url
68-
if (url.includes('about:')) {
69-
browser.browserAction.disable(activeInfo.tabId)
68+
if (url.includes('chrome://')) {
69+
chrome.browserAction.disable(activeInfo.tabId)
7070
}
7171
})
7272
})
7373

7474
// handle tab update(open, reload)
75-
browser.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
75+
chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
7676
// if ((changeInfo.status === 'complete') || (changeInfo.status === 'loading')) {
7777
if (changeInfo.status === 'loading') {
7878
const url = tab.url
7979

8080
if (url.includes('chrome://')) {
81-
browser.browserAction.disable(tabId)
81+
chrome.browserAction.disable(tabId)
8282
} else {
8383
const pureUrl = getPureURL({ url })
8484
storageGet(['thisWebsiteWork', 'thisWebsiteWorkEasy'], (res) => {
@@ -96,7 +96,7 @@ browser.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
9696
})
9797

9898
// messages from content script. Currently responsible for 'alt + x' key comb
99-
browser.runtime.onMessage.addListener((request, sender, sendResponse) => {
99+
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
100100
if (sender.tab) {
101101
const tabId = sender.tab.id
102102
const pureUrl = getPureURL(sender)
@@ -137,7 +137,7 @@ browser.runtime.onMessage.addListener((request, sender, sendResponse) => {
137137
}
138138
})
139139
} else if (request.openOptPage) {
140-
browser.runtime.openOptionsPage()
140+
chrome.runtime.openOptionsPage()
141141
}
142142
}
143143
return true

constants/functions.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@ const storageGet = (request, f) => chrome.storage.sync.get(request, f)
1212
// Browser actions. Badge - text at right bottom corner of extension's icon
1313
const setBadgeText = (text) =>
1414
(tabID) => {
15-
browser.browserAction.setBadgeText({
15+
chrome.browserAction.setBadgeText({
1616
text: text ? text : "",
1717
tabId: tabID ? tabID : null
1818
})
19-
browser.browserAction.setBadgeBackgroundColor({ color: "#222831" })
19+
chrome.browserAction.setBadgeBackgroundColor({ color: "#222831" })
2020
}
2121
const resetBadgeText = setBadgeText('')
2222
// Curried execute script
2323
const executeScript = (tabId) =>
2424
(methodName) =>
25-
browser.tabs.executeScript(
25+
chrome.tabs.executeScript(
2626
tabId,
27-
{file: '/methods/' + methodName + '.js'}
27+
{file: 'methods/' + methodName + '.js'}
2828
)
2929
const executeScriptHere = executeScript(null)
3030

content/content.js

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// local variable for state of current page (do not work after reload)
22
var thisPageOn = false
33

4-
browser.runtime.onMessage.addListener((msg, sender, response) => {
4+
chrome.runtime.onMessage.addListener((msg, sender, response) => {
55
if (msg.method === "getStatusThisPage") {
66
response(thisPageOn)
77
}
@@ -12,13 +12,12 @@ browser.runtime.onMessage.addListener((msg, sender, response) => {
1212
})
1313

1414
document.addEventListener('openOptPage', (e) => {
15-
browser.runtime.sendMessage({ openOptPage: true })
15+
chrome.runtime.sendMessage({ openOptPage: true })
1616
})
1717

1818
const sendStats = () =>
19-
browser.storage.sync.get(['stats'], resp => {
20-
const clonedDetail = cloneInto(resp.stats, document.defaultView)
21-
document.dispatchEvent(new CustomEvent('PopUpOFFStats', { detail: clonedDetail }))
19+
chrome.storage.sync.get(['stats'], resp => {
20+
document.dispatchEvent(new CustomEvent('PopUpOFFStats', { detail: resp.stats }))
2221
})
2322

2423
if (window.location.href === 'https://romanisthere.github.io/secrets/') {
@@ -60,7 +59,7 @@ const keyDownCallBack = (e) => {
6059

6160
if ((e.altKey && e.which == 88) || (isMac && e.metaKey && e.shiftKey && e.which == 88)) {
6261
e.preventDefault()
63-
browser.runtime.sendMessage({ hardMode: true }, (response) => {
62+
chrome.runtime.sendMessage({ hardMode: true }, (response) => {
6463
if (response.shouldShow)
6564
createNotification()
6665
else

css/index.css

+1-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ body {
1212
margin: 0;
1313
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
1414
line-height: 1.59;
15-
font-weight: 300;
16-
17-
overflow: hidden;
15+
font-weight: 300
1816
}
1917

2018
.toggle {

css/options.css

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ html{
44
display: flex;
55

66
align-items: center;
7-
overflow-y: auto;
87

98
--slider-width: 200px;
109
}

manifest.json

+2-5
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"page": "options/options.html",
1515
"open_in_tab": true
1616
},
17+
"content_security_policy": "script-src 'self'; object-src 'self'",
1718
"content_scripts": [
1819
{
1920
"js": [ "content/content.js" ],
@@ -43,9 +44,5 @@
4344
"128": "images/logo128.png"
4445
},
4546
"manifest_version": 2,
46-
"browser_specific_settings": {
47-
"gecko": {
48-
"id": "{154cddeb-4c8b-4627-a478-c7e5b427ffdf}"
49-
}
50-
}
47+
"minimum_chrome_version": "63"
5148
}

methods/removeAll.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ var removeFixedElems = (statsEnabled) => {
22
const getStyle = ($elem, property) => window.getComputedStyle($elem, null).getPropertyValue(property)
33
const setPropImp = ($elem, prop, val) => $elem.style.setProperty(prop, val, "important")
44
const setNewData = state =>
5-
browser.storage.sync.get(['stats'], resp => {
5+
chrome.storage.sync.get(['stats'], resp => {
66
// round to first decimal
77
const screenValue = Math.round(state.cleanedArea/state.windowArea * 10) / 10
88
const newStats = {
@@ -13,7 +13,7 @@ var removeFixedElems = (statsEnabled) => {
1313
if (isNaN(newStats.cleanedArea) || isNaN(newStats.numbOfItems))
1414
return
1515

16-
browser.storage.sync.set({ stats: newStats })
16+
chrome.storage.sync.set({ stats: newStats })
1717
})
1818
const addItemToStats = (element, state) => {
1919
const layoutArea = element.offsetHeight * element.offsetWidth
@@ -83,6 +83,6 @@ var removeFixedElems = (statsEnabled) => {
8383
}
8484
}
8585

86-
browser.storage.sync.get(['statsEnabled'], resp => {
86+
chrome.storage.sync.get(['statsEnabled'], resp => {
8787
removeFixedElems(resp.statsEnabled)
8888
})

methods/removeEasy.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ var punishEasy = (statsEnabled, shouldRestoreCont) => {
2222
return fixedStats
2323
}
2424
const setNewData = state =>
25-
browser.storage.sync.get(['stats'], resp => {
25+
chrome.storage.sync.get(['stats'], resp => {
2626
// round to first decimal
2727
const screenValue = Math.round(state.cleanedArea/state.windowArea * 10) / 10
2828
let newStats = {
@@ -36,7 +36,7 @@ var punishEasy = (statsEnabled, shouldRestoreCont) => {
3636
isNaN(newStats.restored))
3737
newStats = fixStats(newStats)
3838

39-
browser.storage.sync.set({ stats: newStats })
39+
chrome.storage.sync.set({ stats: newStats })
4040
})
4141
const addItemToStats = (element, state) => {
4242
const layoutArea = element.offsetHeight * element.offsetWidth
@@ -324,6 +324,6 @@ var punishEasy = (statsEnabled, shouldRestoreCont) => {
324324
}
325325
}
326326

327-
browser.storage.sync.get(['statsEnabled', 'restoreCont'], resp => {
327+
chrome.storage.sync.get(['statsEnabled', 'restoreCont'], resp => {
328328
punishEasy(resp.statsEnabled, resp.restoreCont)
329329
})

methods/removeHard.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ var punish = (statsEnabled, shouldRestoreCont) => {
2222
return fixedStats
2323
}
2424
const setNewData = state =>
25-
browser.storage.sync.get(['stats'], resp => {
25+
chrome.storage.sync.get(['stats'], resp => {
2626
// round to first decimal
2727
const screenValue = Math.round(state.cleanedArea/state.windowArea * 10) / 10
2828
let newStats = {
@@ -36,7 +36,7 @@ var punish = (statsEnabled, shouldRestoreCont) => {
3636
isNaN(newStats.restored))
3737
newStats = fixStats(newStats)
3838

39-
browser.storage.sync.set({ stats: newStats })
39+
chrome.storage.sync.set({ stats: newStats })
4040
})
4141
const addCountToStats = (state) => {
4242
return { ...state, numbOfItems: parseFloat(state.numbOfItems) + 1 }
@@ -283,6 +283,6 @@ var punish = (statsEnabled, shouldRestoreCont) => {
283283
}
284284
}
285285

286-
browser.storage.sync.get(['statsEnabled', 'restoreCont'], resp => {
286+
chrome.storage.sync.get(['statsEnabled', 'restoreCont'], resp => {
287287
punish(resp.statsEnabled, resp.restoreCont)
288288
})

methods/restore.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ var restoreFixedElems = () => {
1313
arr.map(elem => elem.style.display = null)
1414
}
1515

16-
browser.storage.sync.get("autoWorkEasy", (res) => {
16+
chrome.storage.sync.get("autoWorkEasy", (res) => {
1717
// check if we gonna remove or restore elems
1818
if (res.autoWorkEasy) {
1919

2020
} else {
21-
browser.storage.sync.get("autoWork", (res) => {
21+
chrome.storage.sync.get("autoWork", (res) => {
2222
if (res.autoWork) {
2323

2424
} else {

methods/restoreEasy.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ var restoreFixedElems = () => {
4242
}
4343
}
4444

45-
browser.storage.sync.get("autoWork", (res) => {
45+
chrome.storage.sync.get("autoWork", (res) => {
4646
// check if we gonna remove or restore elems
4747
if (res.autoWork) {
4848

popup/popup.html

-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4-
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
5-
<meta content="utf-8" http-equiv="encoding">
64
<link rel="stylesheet" href="../css/index.css">
75
</head>
86
<body>

popup/popup.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const initTutorial = () => {
4848
return false
4949
}
5050
querySelector('.tutorial_to_options').onclick = () => {
51-
browser.runtime.openOptionsPage()
51+
chrome.runtime.openOptionsPage()
5252
passTutorial()
5353
return false
5454
}
@@ -83,14 +83,14 @@ const showMessage = (className) => {
8383
addClass(querySelector(className), 'message-visible')
8484
if (className == '.message_forb') {
8585
querySelector('.message_forb__link').onclick = () => {
86-
browser.runtime.openOptionsPage()
86+
chrome.runtime.openOptionsPage()
8787
removeClass(querySelector(className), 'message-visible')
8888
return false
8989
}
9090
} else if (className == '.message_reload') {
9191
querySelector('.message_reload__link').onclick = () => {
92-
browser.tabs.query({active: true, currentWindow: true}, (tabs) => {
93-
browser.tabs.update(tabs[0].id, {url: tabs[0].url})
92+
chrome.tabs.query({active: true, currentWindow: true}, (tabs) => {
93+
chrome.tabs.update(tabs[0].id, {url: tabs[0].url})
9494
removeClass(querySelector(className), 'message-visible')
9595
})
9696
return false
@@ -102,7 +102,7 @@ const showMessage = (className) => {
102102

103103
const initToggler = (chInput, otherInput, curMode, otherMode, selector1, selector2, easy) => {
104104
chInput.onchange = (element) => {
105-
browser.tabs.query({active: true, currentWindow: true}, (tabs) => {
105+
chrome.tabs.query({active: true, currentWindow: true}, (tabs) => {
106106
// grab pure url
107107
const newUrl = getPureURL(tabs[0])
108108
const tabID = tabs[0].id
@@ -181,7 +181,7 @@ initToggler(
181181
const toggleThisPageInp = querySelector('#toggleThisPageInp')
182182

183183
toggleThisPageInp.onchange = (element) => {
184-
browser.tabs.query({active: true, currentWindow: true}, (tabs) => {
184+
chrome.tabs.query({active: true, currentWindow: true}, (tabs) => {
185185
const newUrl = getPureURL(tabs[0])
186186
if (IS_SUPERVISION_ACTIVE && ARR_OF_FORB_SITES.includes(newUrl)) {
187187
toggleThisPageInp.checked = false
@@ -191,7 +191,7 @@ toggleThisPageInp.onchange = (element) => {
191191
executeScriptHere('removeAll')
192192
executeScriptHere('showAll')
193193
// sending message to content.js to store is input checked or not to show it when popup open
194-
browser.tabs.sendMessage(
194+
chrome.tabs.sendMessage(
195195
tabs[0].id,
196196
{
197197
method: "setStatusThisPage",
@@ -208,7 +208,7 @@ toggleThisPageInp.onchange = (element) => {
208208
executeScriptHere('restore')
209209
}
210210
showMessage('.message_reload')
211-
browser.tabs.sendMessage(
211+
chrome.tabs.sendMessage(
212212
tabs[0].id,
213213
{
214214
method: "setStatusThisPage",
@@ -243,7 +243,7 @@ const initState = () => {
243243
}
244244
})
245245

246-
browser.tabs.query({active: true, currentWindow: true}, tabs => {
246+
chrome.tabs.query({active: true, currentWindow: true}, tabs => {
247247
let isFirstModeAct = false
248248
const newUrl = getPureURL(tabs[0])
249249

@@ -277,7 +277,7 @@ const initState = () => {
277277
}
278278
})
279279
// I JUST WANT TO READ input state
280-
browser.tabs.sendMessage(
280+
chrome.tabs.sendMessage(
281281
tabs[0].id,
282282
{method: "getStatusThisPage"},
283283
(response) => {

0 commit comments

Comments
 (0)