MCPcopy Create free account
hub / github.com/SKVNDR/FastDork / initializeImportButtonLogic

Function initializeImportButtonLogic

Script/FastDork.js:1998–2084  ·  view source on GitHub ↗
(
    allowListSelectionChange = true,
    { switchToEditList = false } = {}
  )

Source from the content-addressed store, hash-verified

1996 }
1997
1998 async function initializeImportButtonLogic(
1999 allowListSelectionChange = true,
2000 { switchToEditList = false } = {}
2001 ) {
2002 if (!UI.importBtn) return false;
2003 if (!isCurrentlyAutoImporting && !isImportPaused) {
2004 UI.importBtn.style.display = "none";
2005 }
2006 let activeTab;
2007 try {
2008 [activeTab] = await chrome.tabs.query({
2009 active: true,
2010 currentWindow: true,
2011 });
2012 } catch (e) {
2013 console.error("Error querying active tab:", e);
2014 return false;
2015 }
2016 if (!activeTab || !activeTab.id || !activeTab.url?.startsWith("http")) {
2017 if (isCurrentlyAutoImporting || isImportPaused) {
2018 setManualImportButtonState(isCurrentlyAutoImporting, isImportPaused);
2019 }
2020 return false;
2021 }
2022 const currentUrl = activeTab.url;
2023 try {
2024 const allConfigs = await loadSiteConfigs();
2025 let matchingConfig = null;
2026 let matchingDomainKey = null;
2027 for (const domainKey in allConfigs) {
2028 if (Object.prototype.hasOwnProperty.call(allConfigs, domainKey)) {
2029 const config = allConfigs[domainKey];
2030 let isMatch = false;
2031 if (
2032 config.matchPatterns &&
2033 Array.isArray(config.matchPatterns) &&
2034 config.matchPatterns.length > 0
2035 ) {
2036 isMatch = config.matchPatterns.some(
2037 (pattern) => pattern && currentUrl.includes(pattern)
2038 );
2039 }
2040 if (isMatch) {
2041 matchingConfig = config;
2042 matchingDomainKey = domainKey;
2043 console.log(
2044 `Import Logic: Matched URL "${currentUrl}" with config "${domainKey}" (allowChange=${allowListSelectionChange})`
2045 );
2046 break;
2047 }
2048 }
2049 }
2050 if (matchingConfig && matchingDomainKey) {
2051 console.log(
2052 `[initializeImportButtonLogic] Calling setupImportButton for ${matchingDomainKey}`
2053 );
2054 await setupImportButton(
2055 matchingDomainKey,

Callers 5

setupTabStructureFunction · 0.85
handleDeleteSiteSelectorFunction · 0.85
applyImportStatusFunction · 0.85
initializeFunction · 0.85

Calls 6

loadSiteConfigsFunction · 0.85
setupImportButtonFunction · 0.85
showDorkListFunction · 0.85

Tested by

no test coverage detected