From ccf84accb2dd2b8a6bad9c1073360b7656dd73dd Mon Sep 17 00:00:00 2001 From: Joel Torner <joeltorner@gmail.com> Date: Sun, 29 Apr 2018 18:52:09 +0200 Subject: [PATCH 1/2] Add extension link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3ff69385..9dd6ec50 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # TLmanaGer -Chrome extension +[Chrome extension](https://chrome.google.com/webstore/detail/tlmanager/jaimlomiojjmdhipacahmpnfefpbbeig)  From b658dc378a9eae0b7c197e3ddfa31dd2366b1e6b Mon Sep 17 00:00:00 2001 From: Joel Torner <joeltorner@gmail.com> Date: Sun, 29 Apr 2018 20:45:48 +0200 Subject: [PATCH 2/2] Fixing bugs - Options save error - Refactoring - Clean files --- _config.yml | 1 - js/initOptions.js | 30 +++++++++++ js/options.js | 28 ---------- manifest.json | 4 +- src/browser_action/browser_action.html | 2 +- src/inject/inject.js | 73 +++++++++++++------------- src/options/index.html | 1 + 7 files changed, 70 insertions(+), 69 deletions(-) delete mode 100644 _config.yml create mode 100644 js/initOptions.js diff --git a/_config.yml b/_config.yml deleted file mode 100644 index 2f7efbea..00000000 --- a/_config.yml +++ /dev/null @@ -1 +0,0 @@ -theme: jekyll-theme-minimal \ No newline at end of file diff --git a/js/initOptions.js b/js/initOptions.js new file mode 100644 index 00000000..f8b96fa4 --- /dev/null +++ b/js/initOptions.js @@ -0,0 +1,30 @@ +var DEFAULTS = { + optBgLc : "https://images.unsplash.com/photo-1464822759023-fed622ff2c3b?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=35464e00bbef1a93e6958980d587acb5&auto=format&fit=crop&w=1950&q=80", + optProfilePhoto : "../../img/iceberg.svg" +} + +// init options ------------------------------------------------------------------------------------------------ +chrome.storage.sync.get(['optBgLc'], function(result) { + if ($.type(result.optBgLc) == 'undefined'){ + var value = $('#opt-bg-lc').val(); + if ($.type(value) == 'undefined') value = DEFAULTS.optBgLc; + + chrome.storage.sync.set({optBgLc: value }, function() { }); + }else{ + $('#opt-bg-lc').val(result.optBgLc); + } +}); +chrome.storage.sync.get(['optProfilePhoto'], function(result) { + if ($.type(result.optProfilePhoto) == 'undefined') { + var value = $('.opt-profile-set.selected img').attr('src'); + if ($.type(value) == 'undefined') value = DEFAULTS.optProfilePhoto; + + chrome.storage.sync.set({optProfilePhoto: value }, function() {}); + }else{ + if ($('#options-body').length) { + $('#options-body .opt-profile-set').removeClass('selected'); + $('#options-body img[src="'+result.optProfilePhoto+'"]').parents('button').addClass('selected'); + } + } +}); +// end init options -------------------------------------------------------------------------------------------- \ No newline at end of file diff --git a/js/options.js b/js/options.js index c0f67c58..d23a51aa 100644 --- a/js/options.js +++ b/js/options.js @@ -2,18 +2,6 @@ if (window.innerWidth > 500) { $('body').addClass('tw') } -// OPT BG -chrome.storage.sync.get(['optBgLc'], function(result) { - if ($.type(result.optBgLc) == 'undefined') { - - chrome.storage.sync.set({optBgLc: $('#opt-bg-lc').val()}, function() { - - }); - }else{ - $('#opt-bg-lc').val(result.optBgLc); - } -}); - $('#opt-save').click(function(event) { chrome.storage.sync.set({optBgLc: $('#opt-bg-lc').val()}, function() { $('#opt-save-cont').addClass('shown'); @@ -22,21 +10,6 @@ $('#opt-save').click(function(event) { }, 1700) }); }); -// end OPT BG - - -// OPT photo -chrome.storage.sync.get(['optProfilePhoto'], function(result) { - if ($.type(result.optProfilePhoto) == 'undefined') { - - chrome.storage.sync.set({optProfilePhoto: $('.opt-profile-set.selected img').attr('src') }, function() { - - }); - }else{ - $('.opt-profile-set').removeClass('selected'); - $('img[src="'+result.optProfilePhoto+'"]').parents('button').addClass('selected'); - } -}); $('.opt-profile-set').click(function(event) { var $self = $(this); @@ -45,4 +18,3 @@ $('.opt-profile-set').click(function(event) { $self.addClass('selected'); }); }); -// end OPT photo diff --git a/manifest.json b/manifest.json index fdc0655f..92e2cb51 100644 --- a/manifest.json +++ b/manifest.json @@ -1,6 +1,6 @@ { "name": "TLmanaGer", - "version": "1.0.1", + "version": "1.0.2", "manifest_version": 2, "description": "Desarrollamiento tool", "homepage_url": "https://github.com/joelthorner", @@ -51,7 +51,7 @@ "http://8x-os.logicommerce.net/*" ], "js": [ - "src/inject/inject.js" + "js/jquery-3.3.1.min.js", "js/initOptions.js", "src/inject/inject.js" ] } ] diff --git a/src/browser_action/browser_action.html b/src/browser_action/browser_action.html index 04f44772..189e9987 100644 --- a/src/browser_action/browser_action.html +++ b/src/browser_action/browser_action.html @@ -12,7 +12,7 @@ <header class="clearfix"> <img src="../../img/iceberg.svg"> <div class="cont"> - <span id="p-username"><strong>TLmanaGer</strong><span class="badge badge-pill badge-primary">v1.0.1</span></span> + <span id="p-username"><strong>TLmanaGer</strong><span class="badge badge-pill badge-primary">v1.0.2</span></span> <span id="p-mail">Hello, <span id="userNameRes">joelthorner</span></span> </div> <a href="/src/options/index.html" class="icon sett"> diff --git a/src/inject/inject.js b/src/inject/inject.js index e8a5b0ca..3f164897 100644 --- a/src/inject/inject.js +++ b/src/inject/inject.js @@ -1,47 +1,46 @@ chrome.extension.sendMessage({}, function(response) { var readyStateCheckInterval = setInterval(function() { - if (document.readyState === "complete") { - clearInterval(readyStateCheckInterval); + if (document.readyState === "complete") { + clearInterval(readyStateCheckInterval); - // ---------------------------------------------------------- - // This part of the script triggers when page is done loading - // console.log("Hello. This message was sent from scripts/inject.js"); - if (document.getElementById("SML_osUtils")) { - document.getElementById("SML_osUtils").click(); - - function findAncestor (el, cls) { - while ((el = el.parentElement) && !el.classList.contains(cls)); - return el; - } - - setTimeout(function(){ - var _window = findAncestor(document.querySelector('properties[data*="opensaasUtils"]'), 'window') - if (_window) { - _window.classList.add('opensaasWindow'); - var img = ""; - chrome.storage.sync.get(['optBgLc'], function(result) { - console.log(result.optBgLc); - img = result.optBgLc; - - var n=document.createElement("style"),t=document.createTextNode('body{height: calc(100% - 40px);}#windowContainer{top:40px;}.opensaasWindow .windowButtons,.opensaasWindow .windowTitle>span{display:none}.opensaasWindow.window{position:fixed;top:0!important;left:0!important;right:0!important;height:40px!important;border:0}.opensaasWindow.window div.titleBar{background-color:#333}.opensaasWindow.window input.green{position:fixed;top:3px;left:42px;height:34px;border-radius:0;padding-left:0;padding-right:0;width:140px;transition:all 150ms ease;background-color:#222;padding-top:7px}.opensaasWindow.window input.green:hover{background-color:#444}.opensaasWindow.window input.green.__updateCacheProducts__{left:185px}.opensaasWindow.window input.green.__updateCacheCategories__{left:328px}.opensaasWindow.window input.green.__reloadApps__{left:471px}.opensaasWindow.window input.green.__reloadEvents__{left:614px}.opensaasWindow.window input.green.__downloadProjectCode__{left:auto;right:3px;width:34px;padding-top:3px}.opensaasWindow div.windowContent{height:0}.messageBox [value=No]{margin-left:0}.messageBox input[value="Sí"],.messageBox input[value=OK]{width:180px;height:50px;display:block;margin:0 auto 10px;clear:both;float:none;margin-left:auto!important}body{background-image: url('+img+');background-size: cover}.messageBox{top:0!important;left:0!important}.lastposts{display:none !important;}'); - n.appendChild(t); - _window.append(n); - document.getElementById("windowContainer").after( - document.querySelector(".opensaasWindow") - ); - document.querySelector(".opensaasWindow.window input.green.__downloadProjectCode__").value="↓"; - }); + // LC inject ---------------------------------------------------------------- + if (document.getElementById("SML_osUtils")) { + document.getElementById("SML_osUtils").click(); + + function findAncestor (el, cls) { + while ((el = el.parentElement) && !el.classList.contains(cls)); + return el; } - }, 1000); - } + setTimeout(function(){ + var _window = findAncestor(document.querySelector('properties[data*="opensaasUtils"]'), 'window') + if (_window) { + _window.classList.add('opensaasWindow'); + + $('[ls="opensaas.utilCleanCacheCode"]').val('FLUSH'); + $('[ls="opensaas.utilUpdateCacheProducts"]').val('PROD UPDATE'); + $('[ls="opensaas.utilUpdateCacheCategories"]').val('CAT UPDATE'); + $('[ls="opensaas.utilReloadApps"]').val('APP UPDATE'); + $('[ls="opensaas.utilReloadEvents"]').val('EVENT UPDATE'); - // ,setTimeout(function(){for(var e=document.querySelector('properties[data*="opensaasUtils"]'), - // o=[];e=e.parentElement.closest(".window");) - // o.push(e);o[0].addClass("opensaasWindow"); + var img = ""; + chrome.storage.sync.get(['optBgLc'], function(result) { + img = result.optBgLc; - // ---------------------------------------------------------- + var n=document.createElement("style"),t=document.createTextNode('body{height: calc(100% - 40px);}#windowContainer{top:40px;}.opensaasWindow .windowButtons,.opensaasWindow .windowTitle>span{display:none}.opensaasWindow.window{position:fixed;top:0!important;left:0!important;right:0!important;height:40px!important;border:0}.opensaasWindow.window div.titleBar{background-color:#333}.opensaasWindow.window input.green{position:fixed;top:3px;left:42px;height:34px;border-radius:0;padding-left:0;padding-right:0;width:140px;transition:all 150ms ease;background-color:#222;padding-top:7px}.opensaasWindow.window input.green:hover{background-color:#444}.opensaasWindow.window input.green.__updateCacheProducts__{left:185px}.opensaasWindow.window input.green.__updateCacheCategories__{left:328px}.opensaasWindow.window input.green.__reloadApps__{left:471px}.opensaasWindow.window input.green.__reloadEvents__{left:614px}.opensaasWindow.window input.green.__downloadProjectCode__{left:auto;right:3px;width:34px;padding-top:3px}.opensaasWindow div.windowContent{height:0}.messageBox [value=No]{margin-left:0}.messageBox input[value="Sí"],.messageBox input[value=OK]{width:180px;height:50px;display:block;margin:0 auto 10px;clear:both;float:none;margin-left:auto!important}body{background-image: url('+img+');background-size: cover}.messageBox{top:0!important;left:0!important}.lastposts{display:none !important;}'); + n.appendChild(t); + _window.append(n); + document.getElementById("windowContainer").after( + document.querySelector(".opensaasWindow") + ); + document.querySelector(".opensaasWindow.window input.green.__downloadProjectCode__").value="↓"; + $('.taskMenuLink').first().remove(); + }); + } + }, 1000); + } + // LC inject ---------------------------------------------------------------- - } + } }, 10); }); \ No newline at end of file diff --git a/src/options/index.html b/src/options/index.html index 0e520829..bad50ae3 100644 --- a/src/options/index.html +++ b/src/options/index.html @@ -82,6 +82,7 @@ <script src="../../js/jquery-3.3.1.min.js"></script> <script src="../../js/popper.min.js"></script> <script src="../../js/bootstrap.js"></script> + <script src="../../js/initOptions.js"></script> <script src="../../js/options.js"></script> </body> </html> \ No newline at end of file