Skip to content

Commit

Permalink
Merge pull request #13 from ddasutein/update-twitter
Browse files Browse the repository at this point in the history
Version 2.1.0
  • Loading branch information
ddasutein authored Jul 17, 2021
2 parents 0bcac2a + 59e39c8 commit c5b50d6
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 6 deletions.
2 changes: 1 addition & 1 deletion js/Event/Announcement.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
*
*/

document.getElementsByClassName('main-body-section-announcement')[1].style.display ='none';
document.getElementsByClassName('main-body-section-announcement')[0].style.display ='none';
2 changes: 1 addition & 1 deletion js/Event/SaveAsEventHandle.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ chrome.contextMenus.onClicked.addListener(function (info, tab) {
return;
}
else if (info.menuItemId === "saveImage"){
SaveTwitterMedia(tab.url, info.srcUrl);
SaveTwitterMedia(tab.url, info.srcUrl, info.linkUrl);

}
break;
Expand Down
33 changes: 30 additions & 3 deletions js/Event/Twitter/TwitterContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* Twitter supports various image sizes. When using `original`,
* the extension can save images up to 4096x4096 resolution
*/
const size = {
const size = {
small: "&name=small",
medium: "&name=medium",
large: "&name=large",
Expand Down Expand Up @@ -50,11 +50,19 @@ function ViewOriginalMedia(url) {
window.open(updatedUrl, "_blank");
}

function SaveTwitterMedia(tabUrl, url) {
function SaveTwitterMedia(tabUrl, url, linkUrl) {

let fileName;
let fileNameBuilderArray = [];
let tweetId = SplitURL(tabUrl, 5);
let save_image_not_full_view = false;

if (tweetId == null || tweetId.length == 0){
if (!!linkUrl){
tweetId = SplitURL(linkUrl, 5);
save_image_not_full_view = true;
}
}

try {
if (tweetId == null || tweetId.length == 0) {
Expand All @@ -70,7 +78,26 @@ function SaveTwitterMedia(tabUrl, url) {
return key.category == CategoryEnum.Twitter
});

IncludeMentionSymbol = ((bool) => bool ? fileNameBuilderArray.push("@" + SplitURL(tabUrl, 3)) : fileNameBuilderArray.push(SplitURL(tabUrl, 3)));
IncludeMentionSymbol = ((bool) => {
if (bool == true){

if (save_image_not_full_view == true){
fileNameBuilderArray.push("@" + SplitURL(linkUrl, 3));
} else {
fileNameBuilderArray.push("@" + SplitURL(tabUrl, 3));
}

} else {

if (save_image_not_full_view == true){
fileNameBuilderArray.push(SplitURL(linkUrl, 3));
} else {
fileNameBuilderArray.push(SplitURL(tabUrl, 3));
}

}
})

IncludeTweetID = ((bool) => bool ? fileNameBuilderArray.push(tweetId) : false);
IncludeDate = ((bool, settings) => {
settings.filter((x) => {
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "AutoRename",
"short_name": "AutoRename",
"version": "2.0.0",
"version": "2.1.0",
"description": "Rename image files from the internet with a meaningful file name",
"default_locale": "en",
"manifest_version": 2,
Expand Down

0 comments on commit c5b50d6

Please sign in to comment.