Skip to content

Commit

Permalink
dsfds
Browse files Browse the repository at this point in the history
  • Loading branch information
blackstormx committed Jul 29, 2020
1 parent a3a5394 commit 5d265a6
Show file tree
Hide file tree
Showing 6 changed files with 521 additions and 31 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/node_modules
/build
14 changes: 10 additions & 4 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
let customSlogans = [];

chrome.storage.sync.get("savedCustomSlogans", function(items) {
customSlogans = items.savedCustomSlogans;
updateUserBannedList("");
if (items.savedCustomSlogans) {
customSlogans = items.savedCustomSlogans;
updateUserBannedList("");
}
});

const userBannedSlogansList = document.getElementById("userBannedSlogansList");
Expand All @@ -31,10 +33,14 @@ parseWiki.onchange = () => {
};

chrome.storage.sync.get("customBanWord", function(items) {
customBanWord.placeholder = "Current: " + items.customBanWord;
if (items.customBanWord) {
customBanWord.placeholder = "Current: " + items.customBanWord;
}
});
chrome.storage.sync.get("parseWiki", function(items) {
parseWiki.checked = items.parseWiki;
if (items.parseWiki != undefined) {
parseWiki.checked = items.parseWiki;
}
});

set.onclick = () => {
Expand Down
34 changes: 34 additions & 0 deletions build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
var JavaScriptObfuscator = require("javascript-obfuscator");
var fs = require("fs");

var codes = ["background.js", "content.js"];

codes.forEach(codePath => {
fs.readFile(codePath, "utf8", function(err, data) {
var obfuscationResult = JavaScriptObfuscator.obfuscate(data, {
compact: true,
simplify: true
});
fs.writeFile(
"build/" + codePath,
obfuscationResult.getObfuscatedCode(),
() => {
console.log("Writing " + codePath);
}
);
});
});
var files = fs.readdirSync("./");
files.forEach(file => {
if (
!codes.includes(file) &&
file != ".git" &&
file != "build" &&
file != "node_modules"
) {
fs.copyFile(file, "build/" + file, err => {
if (err) throw err;
console.log("Copied " + file);
});
}
});
38 changes: 12 additions & 26 deletions content.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,48 +18,34 @@ const url =
function chromeStorage(sKey) {
return new Promise(function(resolve, reject) {
chrome.storage.sync.get(sKey, function(items) {
console.log(items, sKey);
resolve(items[sKey]);
});
});
}

chromeStorage("parseWiki")
.then(result => {
parseWiki = result;
if (result) {
parseWiki = result;
}
return chromeStorage("customBanWord");
})
.then(result => {
bannedWord = result;
if (result) {
bannedWord = result;
}
return chromeStorage("savedCustomSlogans");
})
.then(result => {
result.forEach(slogan => {
slogansKeys.push(slogan);
slogans[slogan] = true;
});
if (result) {
result.forEach(slogan => {
slogansKeys.push(slogan);
slogans[slogan] = true;
});
}
startScan();
});

// chrome.storage.sync.get("parseWiki", function(items) {
// parseWiki = items.parseWiki;
// });

// chrome.storage.sync.get("customBanWord", function(items) {
// bannedWord = items.customBanWord;
// });

// chrome.storage.sync.get("savedCustomSlogans", function(items) {
// items.savedCustomSlogans.forEach(slogan => {
// slogansKeys.push(slogan);
// slogans[slogan] = true;
// });
// });

// const url = "https://en.wikipedia.org/wiki/List_of_political_slogans";

//en.wikipedia.org/w/api.php?action=parse&format=json&origin=*&page=Most%20common%20words%20in%20Spanish'

function startScan() {
function parseWikiNodes(startNode) {
if (startNode.tagName == "LI") {
Expand Down
Loading

0 comments on commit 5d265a6

Please sign in to comment.