Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,15 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [2.0.0] - 2022-11-01

Fix for #1 Masking-API-Client-Extension is broken for Masking Engine > 6.0.16.0 versions.

## [1.0.0] - 2021-08-08

This is the initial version of the change log. From here on all changed will be
logged here.

# Note:
Please note that if you are using Masking Engine Version <= 6.0.16.0 then only v1.0.0
will work. For Masking Engine > 6.0.16.0 versions please download and use v2.0.0
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@ in interacting easily with Masking API-Client.

# Version

The current `1.X` version is `1.0.0`.
The current `2.X` version is `2.0.0`.

Please see the [Change log](CHANGELOG.md) for
information on each version.

# Note:
Please note that if you are using Masking Engine Version <= 6.0.16.0 then only v1.0.0
will work. For Masking Engine > 6.0.16.0 versions please download and use v2.0.0

# Install

To install this chrome extension follow the below steps:
Expand Down
8 changes: 5 additions & 3 deletions extension/chrome/manifest.json
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"browser_action": {
"action": {
"default_icon": "favicon-128.png",
"default_popup": "popup.html",
"default_title": "Manage Masking API Endpoints"
Expand All @@ -9,7 +9,9 @@
"js": [ "scripts/content.js", "scripts/jquery.min.js", "scripts/utils.js" ],
"matches": [ "*://*/masking/api-client/*" ]
} ],
"content_security_policy": "script-src 'self' https://www.gstatic.com/; object-src 'self'",
"content_security_policy": {
"extension_pages": "script-src 'self'; object-src 'self'; script-src-elem 'self' 'unsafe-inline' https://music.yandex.ru/;"
},
"description": "This extension helps in interacting with Masking API-Client",
"homepage_url": "https://github.com/anilsrivastava1202/",
"icons": {
Expand All @@ -19,7 +21,7 @@
"32": "favicon-32x32.png",
"96": "favicon-96x96.png"
},
"manifest_version": 2,
"manifest_version": 3,
"name": "Delphix Masking API-Client Extension",
"options_page": "settings.html",
"permissions": [ "activeTab", "storage" ],
Expand Down
51 changes: 23 additions & 28 deletions extension/chrome/scripts/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,31 @@ chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
console.log("something happening from the extension");
var data = request.data || {};
if (data.action == 'login') {
var auth_btn = $('#auth_container a')[0];
var auth_btn = document.getElementsByClassName('btn authorize unlocked')[0];
auth_btn.click();
auth_btn = $('#swagger-ui-container div.api-popup-dialog div.auth_submit .auth_logout__button');
if (auth_btn.length != 0) {
var login_button = document.getElementsByClassName('btn modal-btn auth authorize button')[0];
if (typeof(login_button) == undefined) {
if (data.force_logout) {
auth_btn.click(); //logout first
} else {
console.log('Already logged in. Doing nothing');
auth_btn = $('#swagger-ui-container div.api-popup-dialog .api-popup-cancel');
console.log("Logging out before re-logging in.");
auth_btn.click();
} else {
console.log('Already logged in.');
close_btn = document.getElementsByClassName('btn modal-btn auth btn-done button')[0];
close_btn.click();
sendResponse({
data: data,
success: true
});
return;
}

}
//var api_key_input = $('#swagger-ui-container > div.api-popup-dialog > div.api-popup-dialog-wrapper > div.api-popup-content > div > div > div > div.auth_inner > div > div > div > div > div:nth-child(3) > div:nth-child(3) > input');
$(document).ready(function() {
doLogin(data, sendResponse);
});

} else if (data.action == 'isLoggedIn') {
var auth_btn = $('#auth_container a')[0];
auth_btn.click();
auth_btn = $('#swagger-ui-container div.api-popup-dialog div.auth_submit .auth_logout__button');
var cancel_btn = $('#swagger-ui-container div.api-popup-dialog .api-popup-cancel');
cancel_btn.click();
if (auth_btn.length != 0) {
var logged_in_btn = document.getElementsByClassName('btn authorize locked')[0];
if (typeof(logged_in_btn) != undefined && logged_in_btn != null) {
sendResponse({
data: {
'loggedin': true
Expand All @@ -48,11 +43,13 @@ chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
});

} else if (data.action == 'logout') {
var auth_btn = $('#auth_container a')[0];
auth_btn.click();
auth_btn = $('#swagger-ui-container div.api-popup-dialog div.auth_submit .auth_logout__button');
var auth_btn = document.getElementsByClassName('btn authorize locked')[0];
if (auth_btn.length != 0) {
auth_btn.click();
logout_button = document.getElementsByClassName('btn modal-btn auth button')[0];
logout_button.click();
close_button = document.getElementsByClassName('btn modal-btn auth btn-done button')[0];
close_button.click();
sendResponse({
data: data,
success: true
Expand All @@ -69,7 +66,6 @@ chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
input_elem.val(data.input);
trigger_change_event(input_elem[0]);
} else if (data.action == 'getApiEndpoints') {
//var resources = $('#resources li[class="resource"]');
var resources = $('#resources li[class="resource"],#resources li[class="resource active"]');
var endpoints = []

Expand Down Expand Up @@ -152,12 +148,11 @@ var doLogin = function(data, sendResponse) {


var authSuccess = function(data) {
var api_key_input = $('#swagger-ui-container div.api-popup-dialog div.auth_inner input');
//auth_btn = $('#swagger-ui-container > div.api-popup-dialog > div.api-popup-dialog-wrapper > div.api-popup-content > div > div > div > div.auth_submit > button');
api_key_input.val(data.Authorization);
trigger_change_event(api_key_input[0]);
auth_btn = $('#swagger-ui-container div.api-popup-dialog div.auth_submit .auth_submit__button');
auth_btn.click();
console.log('Login action');

}
var api_key_input = document.getElementsByTagName('input')[0];
api_key_input.value = data.Authorization;
trigger_change_event(api_key_input);
var login_button = document.getElementsByClassName('btn modal-btn auth authorize button')[0];
login_button.click();
var close_button = document.getElementsByClassName('btn modal-btn auth btn-done button')[0];
close_button.click();
}