Fixed alwaysUsePreferred bug #96. Added way to customize Popup. Added oldReddit to targets
This commit is contained in:
parent
7ab3b665dc
commit
619f675114
@ -121,7 +121,7 @@ function processDefaultCustomInstances(
|
|||||||
].join('\n<hr>\n');
|
].join('\n<hr>\n');
|
||||||
|
|
||||||
calcNameCheckBoxes();
|
calcNameCheckBoxes();
|
||||||
document.getElementById(`${name}-${protocol}-toogle-all`).addEventListener("change", (event) => {
|
document.getElementById(`${name}-${protocol}-toogle-all`).addEventListener("change", event => {
|
||||||
if (event.target.checked)
|
if (event.target.checked)
|
||||||
nameDefaultRedirects = [...nameHelper.getRedirects()[name][protocol]];
|
nameDefaultRedirects = [...nameHelper.getRedirects()[name][protocol]];
|
||||||
else
|
else
|
||||||
|
@ -55,6 +55,7 @@ async function init() {
|
|||||||
"alwaysUsePreferred",
|
"alwaysUsePreferred",
|
||||||
"theme",
|
"theme",
|
||||||
"applyThemeToSites",
|
"applyThemeToSites",
|
||||||
|
"popupFrontends"
|
||||||
],
|
],
|
||||||
r => { // r = result
|
r => { // r = result
|
||||||
if (r.exceptions) exceptions = r.exceptions;
|
if (r.exceptions) exceptions = r.exceptions;
|
||||||
@ -63,12 +64,52 @@ async function init() {
|
|||||||
theme = r.theme ?? "DEFAULT"
|
theme = r.theme ?? "DEFAULT"
|
||||||
applyThemeToSites = r.applyThemeToSites ?? false;
|
applyThemeToSites = r.applyThemeToSites ?? false;
|
||||||
|
|
||||||
|
popupFrontends = r.popupFrontends ?? [
|
||||||
|
"youtube",
|
||||||
|
"youtubeMusic",
|
||||||
|
"twitter",
|
||||||
|
"instagram",
|
||||||
|
"tikTok",
|
||||||
|
"imgur",
|
||||||
|
"reddit",
|
||||||
|
"search",
|
||||||
|
"translate",
|
||||||
|
"maps",
|
||||||
|
"wikipedia",
|
||||||
|
"medium",
|
||||||
|
];
|
||||||
resolve();
|
resolve();
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
let popupFrontends;
|
||||||
|
const getPopupFrontends = () => popupFrontends;
|
||||||
|
function setPopupFrontends(val) {
|
||||||
|
popupFrontends = val;
|
||||||
|
browser.storage.local.set({ popupFrontends })
|
||||||
|
console.log("popupFrontends: ", val)
|
||||||
|
}
|
||||||
|
|
||||||
|
let allPopupFrontends = [
|
||||||
|
"youtube",
|
||||||
|
"youtubeMusic",
|
||||||
|
"twitter",
|
||||||
|
"instagram",
|
||||||
|
"tikTok",
|
||||||
|
"imgur",
|
||||||
|
"reddit",
|
||||||
|
"pixiv",
|
||||||
|
"search",
|
||||||
|
"translate",
|
||||||
|
"maps",
|
||||||
|
"wikipedia",
|
||||||
|
"medium",
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
getExceptions,
|
getExceptions,
|
||||||
setExceptions,
|
setExceptions,
|
||||||
@ -79,6 +120,11 @@ export default {
|
|||||||
getApplyThemeToSites,
|
getApplyThemeToSites,
|
||||||
setApplyThemeToSites,
|
setApplyThemeToSites,
|
||||||
|
|
||||||
|
getPopupFrontends,
|
||||||
|
setPopupFrontends,
|
||||||
|
|
||||||
|
allPopupFrontends,
|
||||||
|
|
||||||
getTheme,
|
getTheme,
|
||||||
setTheme,
|
setTheme,
|
||||||
|
|
||||||
|
@ -3,13 +3,8 @@ window.browser = window.browser || window.chrome;
|
|||||||
import commonHelper from './common.js'
|
import commonHelper from './common.js'
|
||||||
|
|
||||||
const targets = [
|
const targets = [
|
||||||
/^https?:\/\/reddit\.com/,
|
/^https?:\/\/(www\.|old\.|np\.|new\.|amp\.|)reddit\.com/,
|
||||||
/^https?:\/\/www\.reddit\.com/,
|
/^https?:\/\/(i\.|)redd\.it/,
|
||||||
/^https?:\/\/np\.reddit\.com/,
|
|
||||||
/^https?:\/\/new\.reddit\.com/,
|
|
||||||
/^https?:\/\/amp\.reddit\.com/,
|
|
||||||
/^https?:\/\/i\.redd\.it/,
|
|
||||||
/^https?:\/\/redd\.it/,
|
|
||||||
];
|
];
|
||||||
let redirects = {
|
let redirects = {
|
||||||
// modern UI
|
// modern UI
|
||||||
@ -397,7 +392,7 @@ async function init() {
|
|||||||
|
|
||||||
bypassWatchOnReddit = result.bypassWatchOnReddit ?? true;
|
bypassWatchOnReddit = result.bypassWatchOnReddit ?? true;
|
||||||
|
|
||||||
alwaysUsePreferred = result.alwaysUsePreferred ?? true;
|
alwaysUsePreferred = result.alwaysUsePreferred ?? false;
|
||||||
|
|
||||||
redirects.teddit = dataJson.teddit;
|
redirects.teddit = dataJson.teddit;
|
||||||
if (result.redditRedirects) redirects = result.redditRedirects;
|
if (result.redditRedirects) redirects = result.redditRedirects;
|
||||||
|
@ -245,7 +245,7 @@ async function init() {
|
|||||||
|
|
||||||
bypassWatchOnTwitter = r.bypassWatchOnTwitter ?? true;
|
bypassWatchOnTwitter = r.bypassWatchOnTwitter ?? true;
|
||||||
|
|
||||||
alwaysUsePreferred = r.alwaysUsePreferred ?? true;
|
alwaysUsePreferred = r.alwaysUsePreferred ?? false;
|
||||||
|
|
||||||
theme = r.theme ?? 'DEFAULT';
|
theme = r.theme ?? 'DEFAULT';
|
||||||
applyThemeToSites = r.applyThemeToSites ?? false;
|
applyThemeToSites = r.applyThemeToSites ?? false;
|
||||||
|
@ -618,7 +618,6 @@ function addUrlParams(url) {
|
|||||||
else return;
|
else return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function initPipedLocalStorage(tabId) {
|
function initPipedLocalStorage(tabId) {
|
||||||
browser.tabs.executeScript(
|
browser.tabs.executeScript(
|
||||||
tabId,
|
tabId,
|
||||||
@ -736,7 +735,7 @@ async function init() {
|
|||||||
|
|
||||||
persistInvidiousPrefs = r.persistInvidiousPrefs ?? false;
|
persistInvidiousPrefs = r.persistInvidiousPrefs ?? false;
|
||||||
|
|
||||||
alwaysUsePreferred = r.alwaysUsePreferred ?? true;
|
alwaysUsePreferred = r.alwaysUsePreferred ?? false;
|
||||||
|
|
||||||
bypassWatchOnYoutube = r.bypassWatchOnYoutube ?? true;
|
bypassWatchOnYoutube = r.bypassWatchOnYoutube ?? true;
|
||||||
|
|
||||||
|
@ -32,7 +32,6 @@ async function wholeInit() {
|
|||||||
tiktokHelper.init()
|
tiktokHelper.init()
|
||||||
pixivHelper.init()
|
pixivHelper.init()
|
||||||
generalHelper.init()
|
generalHelper.init()
|
||||||
|
|
||||||
}
|
}
|
||||||
wholeInit();
|
wholeInit();
|
||||||
|
|
||||||
|
@ -89,7 +89,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|
||||||
<section class="option-block">
|
<section class="option-block">
|
||||||
<div class="some-block option-block">
|
<div class="some-block option-block">
|
||||||
<h4>Theme</h4>
|
<h4>Theme</h4>
|
||||||
@ -176,6 +175,29 @@
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<div class="some-block option-block">
|
||||||
|
<h4>Customize Popup</h4>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="checklist" id="popup-frontends-checklist">
|
||||||
|
<div>Youtube<input type="checkbox" id="youtube" /></div>
|
||||||
|
<div>YoutubeMusic<input type="checkbox" id="youtubeMusic" /></div>
|
||||||
|
<div>Twitter<input type="checkbox" id="twitter" /></div>
|
||||||
|
<div>Instagram<input type="checkbox" id="instagram" /></div>
|
||||||
|
<div>TikTok<input type="checkbox" id="tikTok" /></div>
|
||||||
|
<div>Imgur<input type="checkbox" id="imgur" /></div>
|
||||||
|
<div>Reddit<input type="checkbox" id="reddit" /></div>
|
||||||
|
<div>Pixiv<input type="checkbox" id="pixiv" /></div>
|
||||||
|
<div>Search<input type="checkbox" id="search" /></div>
|
||||||
|
<div>Translate<input type="checkbox" id="translate" /></div>
|
||||||
|
<div>Maps<input type="checkbox" id="maps" /></div>
|
||||||
|
<div>Wikipedia<input type="checkbox" id="wikipedia" /></div>
|
||||||
|
<div>Medium<input type="checkbox" id="medium" /></div>
|
||||||
|
</div>
|
||||||
|
<hr>
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<script type="module" src="../init.js"></script>
|
<script type="module" src="../init.js"></script>
|
||||||
|
@ -76,12 +76,27 @@ let nameCustomInstanceInput = document.getElementById("exceptions-custom-instanc
|
|||||||
let instanceTypeElement = document.getElementById("exceptions-custom-instance-type");
|
let instanceTypeElement = document.getElementById("exceptions-custom-instance-type");
|
||||||
let instanceType = "url"
|
let instanceType = "url"
|
||||||
|
|
||||||
|
let popupFrontends;
|
||||||
|
for (const frontend of generalHelper.allPopupFrontends)
|
||||||
|
document.getElementById(frontend).addEventListener("change",
|
||||||
|
event => {
|
||||||
|
if (event.target.checked && !popupFrontends.includes(frontend))
|
||||||
|
popupFrontends.push(frontend)
|
||||||
|
else if (popupFrontends.includes(frontend)) {
|
||||||
|
var index = popupFrontends.indexOf(frontend);
|
||||||
|
if (index !== -1) popupFrontends.splice(index, 1);
|
||||||
|
}
|
||||||
|
generalHelper.setPopupFrontends(popupFrontends);
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
generalHelper.init().then(() => {
|
generalHelper.init().then(() => {
|
||||||
alwaysUsePreferredElement.checked = generalHelper.getAlwaysUsePreferred();
|
alwaysUsePreferredElement.checked = generalHelper.getAlwaysUsePreferred();
|
||||||
|
console.log("alwaysUsePreferredElement.checked", alwaysUsePreferredElement.checked);
|
||||||
themeElement.value = generalHelper.getTheme();
|
themeElement.value = generalHelper.getTheme();
|
||||||
applyThemeToSitesElement.checked = generalHelper.getApplyThemeToSites();
|
applyThemeToSitesElement.checked = generalHelper.getApplyThemeToSites();
|
||||||
instanceTypeElement.addEventListener("change",
|
instanceTypeElement.addEventListener("change",
|
||||||
(event) => {
|
event => {
|
||||||
instanceType = event.target.options[instanceTypeElement.selectedIndex].value
|
instanceType = event.target.options[instanceTypeElement.selectedIndex].value
|
||||||
if (instanceType == 'url') {
|
if (instanceType == 'url') {
|
||||||
nameCustomInstanceInput.setAttribute("type", "url");
|
nameCustomInstanceInput.setAttribute("type", "url");
|
||||||
@ -149,4 +164,8 @@ generalHelper.init().then(() => {
|
|||||||
}
|
}
|
||||||
calcExceptionsCustomInstances();
|
calcExceptionsCustomInstances();
|
||||||
})
|
})
|
||||||
|
|
||||||
|
popupFrontends = generalHelper.getPopupFrontends();
|
||||||
|
for (const frontend of generalHelper.allPopupFrontends)
|
||||||
|
document.getElementById(frontend).checked = popupFrontends.includes(frontend);
|
||||||
})
|
})
|
@ -9,7 +9,7 @@
|
|||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div class="some-block">
|
<div id="youtube" class="some-block">
|
||||||
<div class="title">
|
<div class="title">
|
||||||
<img src="../../assets/images/youtube-icon.png" />
|
<img src="../../assets/images/youtube-icon.png" />
|
||||||
<h4>YouTube</h4>
|
<h4>YouTube</h4>
|
||||||
@ -17,7 +17,7 @@
|
|||||||
<input id="disable-youtube" type="checkbox" checked />
|
<input id="disable-youtube" type="checkbox" checked />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="some-block">
|
<div id="youtubeMusic" class="some-block">
|
||||||
<div class="title">
|
<div class="title">
|
||||||
<img src="../../assets/images/youtube-music-icon.png" />
|
<img src="../../assets/images/youtube-music-icon.png" />
|
||||||
<h4>YT Music</h4>
|
<h4>YT Music</h4>
|
||||||
@ -25,7 +25,7 @@
|
|||||||
<input id="disable-youtubeMusic" type="checkbox" checked />
|
<input id="disable-youtubeMusic" type="checkbox" checked />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="some-block">
|
<div id="twitter" class="some-block">
|
||||||
<div class="title">
|
<div class="title">
|
||||||
<img src="../../assets/images/twitter-icon.png" />
|
<img src="../../assets/images/twitter-icon.png" />
|
||||||
<h4>Twitter</h4>
|
<h4>Twitter</h4>
|
||||||
@ -33,7 +33,7 @@
|
|||||||
<input id="disable-nitter" type="checkbox" checked />
|
<input id="disable-nitter" type="checkbox" checked />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="some-block">
|
<div id="instagram" class="some-block">
|
||||||
<div class="title">
|
<div class="title">
|
||||||
<!-- https://www.iconfinder.com/Indygo -->
|
<!-- https://www.iconfinder.com/Indygo -->
|
||||||
<img src="../../assets/images/instagram-icon.png" />
|
<img src="../../assets/images/instagram-icon.png" />
|
||||||
@ -42,7 +42,7 @@
|
|||||||
<input id="disable-bibliogram" type="checkbox" checked />
|
<input id="disable-bibliogram" type="checkbox" checked />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="some-block">
|
<div id="tikTok" class="some-block">
|
||||||
<div class="title">
|
<div class="title">
|
||||||
<!-- https://www.flaticon.com/authors/designer-shah -->
|
<!-- https://www.flaticon.com/authors/designer-shah -->
|
||||||
<img src="../../assets/images/tiktok-icon.png" />
|
<img src="../../assets/images/tiktok-icon.png" />
|
||||||
@ -51,7 +51,7 @@
|
|||||||
<input id="disable-tiktok" type="checkbox" checked />
|
<input id="disable-tiktok" type="checkbox" checked />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="some-block">
|
<div id="imgur" class="some-block">
|
||||||
<div class="title">
|
<div class="title">
|
||||||
<img src="../../assets/images/imgur-icon.png" />
|
<img src="../../assets/images/imgur-icon.png" />
|
||||||
<h4>Imgur</h4>
|
<h4>Imgur</h4>
|
||||||
@ -59,7 +59,7 @@
|
|||||||
<input id="disable-imgur" type="checkbox" checked />
|
<input id="disable-imgur" type="checkbox" checked />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="some-block">
|
<div id="reddit" class="some-block">
|
||||||
<div class="title">
|
<div class="title">
|
||||||
<!-- https://www.flaticon.com/authors/md-tanvirul-haque -->
|
<!-- https://www.flaticon.com/authors/md-tanvirul-haque -->
|
||||||
<img src="../../assets/images/reddit-icon.png" />
|
<img src="../../assets/images/reddit-icon.png" />
|
||||||
@ -68,7 +68,7 @@
|
|||||||
<input id="disable-reddit" type="checkbox" checked />
|
<input id="disable-reddit" type="checkbox" checked />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="some-block">
|
<div id="pixiv" class="some-block">
|
||||||
<div class="title">
|
<div class="title">
|
||||||
<!-- https://clipground.com/pics/getsecond?url=pixiv-logo-2.png -->
|
<!-- https://clipground.com/pics/getsecond?url=pixiv-logo-2.png -->
|
||||||
<img src="../../assets/images/pixiv-icon.png" />
|
<img src="../../assets/images/pixiv-icon.png" />
|
||||||
@ -77,7 +77,7 @@
|
|||||||
<input id="disable-pixiv" type="checkbox" checked />
|
<input id="disable-pixiv" type="checkbox" checked />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="some-block">
|
<div id="wikipedia" class="some-block">
|
||||||
<div class="title">
|
<div class="title">
|
||||||
<img src="../../../assets/images/wikipedia-icon.svg" />
|
<img src="../../../assets/images/wikipedia-icon.svg" />
|
||||||
<h4>Wikipedia</h4>
|
<h4>Wikipedia</h4>
|
||||||
@ -85,7 +85,7 @@
|
|||||||
<input id="disable-wikipedia" type="checkbox" checked />
|
<input id="disable-wikipedia" type="checkbox" checked />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="some-block">
|
<div id="medium" class="some-block">
|
||||||
<div class="title">
|
<div class="title">
|
||||||
<!-- https://markentier.tech/posts/2020/10/medium-icon-svg/ -->
|
<!-- https://markentier.tech/posts/2020/10/medium-icon-svg/ -->
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1770 1000" fill="currentColor">
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1770 1000" fill="currentColor">
|
||||||
@ -98,8 +98,7 @@
|
|||||||
<input id="disable-medium" type="checkbox" checked />
|
<input id="disable-medium" type="checkbox" checked />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="some-block">
|
<div id="search" class="some-block">
|
||||||
|
|
||||||
<div class="title">
|
<div class="title">
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
|
||||||
<path d="M0 0h24v24H0V0z" fill="none" />
|
<path d="M0 0h24v24H0V0z" fill="none" />
|
||||||
@ -108,11 +107,10 @@
|
|||||||
</svg>
|
</svg>
|
||||||
<h4>Search</h4>
|
<h4>Search</h4>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<input id="disable-search" type="checkbox" checked />
|
<input id="disable-search" type="checkbox" checked />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="some-block">
|
<div id="translate" class="some-block">
|
||||||
<div class="title">
|
<div class="title">
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor">
|
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor">
|
||||||
<path d="M0 0h24v24H0V0z" fill="none" />
|
<path d="M0 0h24v24H0V0z" fill="none" />
|
||||||
@ -124,7 +122,7 @@
|
|||||||
<input id="disable-simplyTranslate" type="checkbox" checked />
|
<input id="disable-simplyTranslate" type="checkbox" checked />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="some-block">
|
<div id="maps" class="some-block">
|
||||||
<div class="title">
|
<div class="title">
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor">
|
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor">
|
||||||
<path d="M0 0h24v24H0V0z" fill="none" />
|
<path d="M0 0h24v24H0V0z" fill="none" />
|
||||||
|
@ -15,6 +15,7 @@ import mediumHelper from "../../assets/javascripts/helpers/medium.js";
|
|||||||
import imgurHelper from "../../assets/javascripts/helpers/imgur.js";
|
import imgurHelper from "../../assets/javascripts/helpers/imgur.js";
|
||||||
import tiktokHelper from "../../assets/javascripts/helpers/tiktok.js";
|
import tiktokHelper from "../../assets/javascripts/helpers/tiktok.js";
|
||||||
import pixivHelper from "../../assets/javascripts/helpers/pixiv.js";
|
import pixivHelper from "../../assets/javascripts/helpers/pixiv.js";
|
||||||
|
import generalHelper from "../../assets/javascripts/helpers/general.js";
|
||||||
|
|
||||||
let disableTwitterElement = document.getElementById("disable-nitter");
|
let disableTwitterElement = document.getElementById("disable-nitter");
|
||||||
let disableYoutubeElement = document.getElementById("disable-youtube");
|
let disableYoutubeElement = document.getElementById("disable-youtube");
|
||||||
@ -157,3 +158,17 @@ function changeInstance() {
|
|||||||
let changeInstanceElement = document.getElementById("change-instance")
|
let changeInstanceElement = document.getElementById("change-instance")
|
||||||
changeInstanceElement.disabled = !changeInstance();
|
changeInstanceElement.disabled = !changeInstance();
|
||||||
changeInstanceElement.addEventListener("click", changeInstance);
|
changeInstanceElement.addEventListener("click", changeInstance);
|
||||||
|
|
||||||
|
|
||||||
|
let popupFrontends;
|
||||||
|
generalHelper.init().then(() => {
|
||||||
|
popupFrontends = generalHelper.getPopupFrontends();
|
||||||
|
|
||||||
|
for (const frontend of generalHelper.allPopupFrontends) {
|
||||||
|
console.log(frontend)
|
||||||
|
if (!popupFrontends.includes(frontend))
|
||||||
|
document.getElementById(frontend).classList.add("hide")
|
||||||
|
else
|
||||||
|
document.getElementById(frontend).classList.remove("hide")
|
||||||
|
}
|
||||||
|
});
|
@ -1,4 +1,8 @@
|
|||||||
body {
|
body {
|
||||||
width: 240px;
|
width: 240px;
|
||||||
min-height: auto;
|
min-height: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hide {
|
||||||
|
display: none !important;
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user