Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No-editor, no-eval branch #2186

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
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
13 changes: 6 additions & 7 deletions Extensions/audio_plus.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,10 @@ XKit.extensions.audio_plus = {
},

create_pop_out_controls: function() {
const controls_markup = `

var psuedo_post = document.createElement("div");
psuedo_post.classList.add("xkit-audio-plus-pseudo-post");
psuedo_post.innerHTML = `
<div class="xkit-audio-plus-controls audio-player">
<div class="progress"></div>
<div class="play-pause">
Expand All @@ -245,10 +248,6 @@ XKit.extensions.audio_plus = {
<div id="xkit-audio-plus-controls-undock"></div>
</div>
`;

var psuedo_post = document.createElement("div");
psuedo_post.classList.add("xkit-audio-plus-pseudo-post");
psuedo_post.innerHTML = controls_markup;
document.body.appendChild(psuedo_post);

this.pop_out_controls = psuedo_post;
Expand Down Expand Up @@ -384,11 +383,11 @@ XKit.extensions.audio_plus = {
this.icon_observer.observe(pause_icon, config);

if (player.querySelector(".track-name").innerHTML != "") {
this.pop_out_controls_track_name.innerHTML = player.querySelector(".track-name").innerHTML;
this.pop_out_controls_track_name.replaceChildren(player.querySelector(".track-name").cloneNode(true));
} else {
this.pop_out_controls_track_name.innerHTML = "Listen";
}
this.pop_out_controls_track_artist.innerHTML = player.querySelector(".track-artist").innerHTML;
this.pop_out_controls_track_artist.replaceChildren(player.querySelector(".track-artist").cloneNode(true));

this.current_player = player;
this.pop_out_controls.classList.add("showing");
Expand Down
2 changes: 1 addition & 1 deletion Extensions/old_stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ XKit.extensions.old_stats = new Object({
$(".no_push.selected_blog, .no_push.old_stats_blog").last().css("margin", "0 0 18px");

$(".old_stats_blog").click(function() {
$(".no_push.selected_blog .open_blog.with_subtitle")[0].outerHTML = this.firstChild.outerHTML.replace("span", "a");
// $(".no_push.selected_blog .open_blog.with_subtitle")[0].outerHTML = this.firstChild.outerHTML.replace("span", "a");
loading = true;
$("#old_stats_switcher").click();
XKit.extensions.old_stats.fetchStats($(this).find(".currently_selected_blog").html());
Expand Down
9 changes: 7 additions & 2 deletions Extensions/servant.js
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ XKit.extensions.servant = new Object({

run_js: {

text: "Run Javascript Code",
text: "Run Javascript Code (disabled)",
compatibility: "",
type: "textarea",
placeholder: "ie: 'if (mary.has_lamb == true) {\n\treturn true;\n }'",
Expand All @@ -731,7 +731,10 @@ XKit.extensions.servant = new Object({
var m_return = false;

try {
/*
m_return = new Function(parameter + "\n//# sourceURL=xkit/servant/servant" + (new Date()).getTime() + ".js")();
*/
throw new Error('"Run Javascript Code" cause is disabled.');
} catch (e) {
m_return = false;
console.error("Unable to run Servant! ---> " + e.message);
Expand Down Expand Up @@ -1115,7 +1118,7 @@ XKit.extensions.servant = new Object({

run_js: {

text: "Run Javascript Code",
text: "Run Javascript Code (disabled)",
compatibility: "",
type: "textarea",
placeholder: "ie: 'alert(&quot;%1 happened!&quot;);'",
Expand All @@ -1142,7 +1145,9 @@ XKit.extensions.servant = new Object({
var post = m_post[0];
}

/*
new Function(parameter_fixed + "\n//# sourceURL=xkit/servant/servant" + (new Date()).getTime() + ".js")();
*/

}

Expand Down
6 changes: 3 additions & 3 deletions Extensions/xkit_installer.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ XKit.extensions.xkit_installer = new Object({
console.log("Will be installing " + to_install);
$("#xkit-install-process").html("Installing package " + to_install + "...");

XKit.install(to_install, function(mdata) {
XKit.install(to_install, async function(mdata) {
// defined in xkit.js
/* globals show_error_installation */

Expand All @@ -125,9 +125,9 @@ XKit.extensions.xkit_installer = new Object({
}

try {
// Try evaling the script.
// Try importing the script.
// If it's working, then move to the next one.
new Function(mdata.script + "\n//# sourceURL=xkit/" + mdata.id + ".js")();
await mdata.import();
XKit.extensions.xkit_installer.installed++;
XKit.extensions.xkit_installer.next();
} catch (e) {
Expand Down
2 changes: 1 addition & 1 deletion Extensions/xkit_main.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
}

try {
new Function(extension.script + "\n//# sourceURL=xkit/" + extension.id + ".js")();
await extension.import();

if (typeof XKit.extensions[extension.id].preferences !== "undefined") {
this.load_extension_preferences(extension.id);
Expand Down
5 changes: 3 additions & 2 deletions Extensions/xkit_patches.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ XKit.extensions.xkit_patches = new Object({
if (XKit.browser().firefox === true && XKit.storage.get("xkit_patches", "w_edition_warned") !== "true") {
let version = XKit.tools.parse_version(XKit.version);
if (version.major === 7 && version.minor >= 8) {
fetch(browser.extension.getURL("manifest.json")) // eslint-disable-line no-undef
fetch(browser.runtime.getURL("manifest.json")) // eslint-disable-line no-undef
.then(response => response.json())
.then(responseData => {
if (responseData.applications.gecko.id === "@new-xkit-w") {
if (responseData.applications && responseData.applications.gecko.id === "@new-xkit-w" ||
responseData.browser_specific_settings && responseData.browser_specific_settings.gecko.id === "@new-xkit-w") {
XKit.window.show(
"W Edition warning",
"XKit Patches has determined that you are using <br><b>New XKit (W Edition)</b>, an unofficial upload of New XKit.<br><br>" +
Expand Down
77 changes: 2 additions & 75 deletions Extensions/xkit_preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -996,7 +996,7 @@ XKit.extensions.xkit_preferences = new Object({

$(this).parent().addClass("overlayed");

XKit.install($(this).attr('data-extension-id'), function(extension_data) {
XKit.install($(this).attr('data-extension-id'), async function(extension_data) {
// defined in xkit.js
/* globals show_error_installation */

Expand All @@ -1023,7 +1023,7 @@ XKit.extensions.xkit_preferences = new Object({
$("#xkit-gallery-extension-" + extension_data.id).find(".overlay").html("Installed!");

try {
new Function(extension_data.script + "\n//# sourceURL=xkit/" + m_extension_id + ".js")();
await extension_data.import();
XKit.extensions.xkit_main.load_extension_preferences(m_extension_id);
if (XKit.installed.enabled(m_extension_id)) {
XKit.extensions[m_extension_id].run();
Expand Down Expand Up @@ -1321,8 +1321,6 @@ XKit.extensions.xkit_preferences = new Object({

m_html = m_html + '</div><div class="buttons">';

m_html = m_html + '<div class="xkit-button" id="xkit-extension-update">Update</div>';

if (!this_is_internal) {
m_html = m_html + '<div class="xkit-button" id="xkit-extension-uninstall">Uninstall</div>';
m_html = m_html + '<div class="xkit-button" id="xkit-extension-reset">Reset Settings</div>';
Expand Down Expand Up @@ -1415,46 +1413,6 @@ XKit.extensions.xkit_preferences = new Object({

});

$("#xkit-extension-update").click(function() {

var $this = $(this);

if ($this.hasClass("disabled") === true) { return; }

$("#xkit-extensions-panel-right-inner").html('<div id="xkit-extension-panel-no-settings">Updating...</div>');

if (typeof XKit.extensions.xkit_updates === "undefined" || typeof XKit.extensions.xkit_updates.update === "undefined") {
XKit.window.show("Can't update",
'It looks like "XKit Updates" extension is missing or not working properly. It is highly recommended that you reset XKit.', "error",
'<div id="xkit-close-message" class="xkit-button default">OK</div>' +
'<a href="http://www.tumblr.com/xkit_reset" class="xkit-button">Reset XKit</a>');
XKit.extensions.xkit_preferences.open_extension_control_panel(XKit.extensions.xkit_preferences.current_open_extension_panel);
return;
}

$(this).addClass("disabled");

XKit.extensions.xkit_updates.update(XKit.extensions.xkit_preferences.current_open_extension_panel, function(mdata) {

if (mdata.errors === false) {
XKit.window.show("Done!", "<b>Done updating extension.</b><br/>" +
"Please refresh the page for changes to take effect.", "info",
'<div id="xkit-close-message" class="xkit-button default">OK</div>');
XKit.extensions.xkit_preferences.open_extension_control_panel(XKit.extensions.xkit_preferences.current_open_extension_panel);
return;
}

XKit.window.show("Can't update",
"Update manager returned the following message:<p>" + mdata.error + "</p>" +
"Please try again later or if the problem continues, contact New XKit Support.", "error",
'<div id="xkit-close-message" class="xkit-button default">OK</div>' +
'<a href="http://new-xkit-support.tumblr.com/support" class="xkit-button">Support Chat Room</a>');
XKit.extensions.xkit_preferences.open_extension_control_panel(XKit.extensions.xkit_preferences.current_open_extension_panel);

});

});

$("#xkit-extension-reset").click(function() {

if (typeof XKit.extensions[extension_id] === "undefined") {
Expand Down Expand Up @@ -1991,7 +1949,6 @@ XKit.extensions.xkit_preferences = new Object({
'<div class="nano long" id="xkit-extensions-panel-left">' +
'<div class="content" id="xkit-extensions-panel-left-inner">' +
'<div class="xkit-extension text-only separator">Configuration</div>' +
'<div data-pname="update-all" class="xkit-extension text-only">Update All</div>' +
'<div data-pname="reset" class="xkit-extension text-only">Reset XKit</div>' +
'<div data-pname="config" class="xkit-extension text-only">Export Configuration</div>' +
'<div data-pname="storage" class="xkit-extension text-only">Storage</div>' +
Expand Down Expand Up @@ -2029,9 +1986,6 @@ XKit.extensions.xkit_preferences = new Object({
if ($this.attr('data-pname') === "updates") {
XKit.extensions.xkit_preferences.show_others_panel_updates();
}
if ($this.attr('data-pname') === "update-all") {
XKit.extensions.xkit_preferences.show_others_panel_update_all();
}
if ($this.attr('data-pname') === "news") {
XKit.extensions.xkit_preferences.show_others_panel_news();
}
Expand Down Expand Up @@ -2324,33 +2278,6 @@ XKit.extensions.xkit_preferences = new Object({

},

show_others_panel_update_all: function() {

var m_html =
'<div class="xkit-others-panel">' +
'<div class="title">Update All</div>' +
'<div class="description">' +
"If you would like to force XKit to update itself now, or for some reason, you can not receive updates, click the button below to trigger Automatic Updates now. XKit will check for the new versions of extensions and update them if necessary." +
"</div>" +
'<div class="bottom-part">' +
'<div id="xkit-panel-force-update-xkit" class="xkit-button block">Update all my extensions</div>' +
"</div>" +
"</div>";

$("#xkit-extensions-panel-right-inner").html(m_html);
$("#xkit-extensions-panel-right").nanoScroller();

$("#xkit-panel-force-update-xkit").click(function() {

XKit.window.show("Forcing Automatic Updates",
"Please wait while I review the changes and update myself..<br/>Please do not navigate away from this page." +
'<div id="xkit-forced-auto-updates-message">Initializing...</div>', "info");
XKit.extensions.xkit_updates.get_list(true);

});

},

show_others_panel_open_editor: function() {

var m_html =
Expand Down
8 changes: 7 additions & 1 deletion Extensions/xkit_updates.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
//* TITLE XKit Updates **//
//* VERSION 2.1.3 **//
//* DESCRIPTION Provides automatic updating of extensions **//
//* DESCRIPTION Deprecated (installed for compatibility) **//
//* DEVELOPER new-xkit **//
XKit.extensions.xkit_updates = new Object({

running: false,

run: function() {
this.running = true;
},

/*
default_interval: 18000000,
min_interval: 3600000,
max_interval: 86400000,
Expand Down Expand Up @@ -259,6 +264,7 @@ XKit.extensions.xkit_updates = new Object({
}
return false;
},
*/

destroy: function() {
this.running = false;
Expand Down
2 changes: 1 addition & 1 deletion bridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function getBridgeError() { // eslint-disable-line no-redeclare

function getVersion() {
var xhr = new XMLHttpRequest();
xhr.open('GET', browser.extension.getURL('manifest.json'), false);
xhr.open('GET', browser.runtime.getURL('manifest.json'), false);
xhr.send(null);
var manifest = JSON.parse(xhr.responseText);
return manifest.version;
Expand Down
Loading