Skip to content

Commit

Permalink
Merge pull request #17 from HoangTran0410/dev
Browse files Browse the repository at this point in the history
Fix all click content script, optimize autorun scripts
  • Loading branch information
HoangTran0410 authored Apr 8, 2024
2 parents ab1c790 + 9db6c7c commit 7b14c32
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 45 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Donate? Muốn hỗ trợ mình 1 ly cafe <3 [Donate here](https://github.com/Ho

## Lịch sử cập nhật

Verion hiện tại: <del>v1.1</del> <del>v1.2</del> <del>v1.3</del> <del>v1.4</del> <del>v1.5</del> <del>v1.6</del> **v1.64-hotfix** (03/04/2024)
Verion hiện tại: <del>v1.1</del> <del>v1.2</del> <del>v1.3</del> <del>v1.4</del> <del>v1.5</del> <del>v1.6</del> <del>v1.64-hotfix</del> **v1.65-hotfix** (08/04/2024)

[Lịch sử cập nhật](/md/CHANGELOGS.md)

Expand Down
14 changes: 9 additions & 5 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 3,
"name": "Useful Scripts",
"description": "Scripts that can make your life faster and better",
"version": "1.64",
"version": "1.65",
"icons": {
"16": "./assets/icon16.png",
"32": "./assets/icon32.png",
Expand Down Expand Up @@ -33,7 +33,8 @@
"run_at": "document_start",
"world": "ISOLATED",
"match_origin_as_fallback": true,
"match_about_blank": true
"match_about_blank": true,
"all_frames": true
},
{
"matches": ["<all_urls>"],
Expand All @@ -44,23 +45,26 @@
"run_at": "document_start",
"world": "MAIN",
"match_origin_as_fallback": true,
"match_about_blank": true
"match_about_blank": true,
"all_frames": true
},
{
"matches": ["<all_urls>"],
"js": ["scripts/content-scripts/document_idle.js"],
"run_at": "document_idle",
"world": "MAIN",
"match_origin_as_fallback": true,
"match_about_blank": true
"match_about_blank": true,
"all_frames": true
},
{
"matches": ["<all_urls>"],
"js": ["scripts/content-scripts/document_end.js"],
"run_at": "document_end",
"world": "MAIN",
"match_origin_as_fallback": true,
"match_about_blank": true
"match_about_blank": true,
"all_frames": true
}
],
"web_accessible_resources": [
Expand Down
13 changes: 13 additions & 0 deletions md/CHANGELOGS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
## Change logs

<details>
<summary>v1564-hotfix - 08/04/2024</summary>

Fix các chức năng tự động chạy

Optimize scripts autorun

Bữa 03/04 fix chưa hết :(

[Tất cả Chức năng](./LIST_SCRIPTS_VI.md)

</details>

<details>
<summary>v1.64-hotfix - 03/04/2024</summary>

Expand Down
3 changes: 2 additions & 1 deletion scripts/content-scripts/run_scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
runScripts(ids, detail.event, path);
});

const data = await UsefulScriptGlobalPageContext.Extension.getActiveScripts();
const data =
await UsefulScriptGlobalPageContext?.Extension?.getActiveScripts?.();
console.log(data);
ids = data?.ids?.split(",") || [];
path = data?.path || "";
Expand Down
7 changes: 2 additions & 5 deletions scripts/search_userscript.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export default {
icon: "https://www.tampermonkey.net/favicon.ico",
icon: "https://www.userscript.zone/favicon.ico",
name: {
en: "Search Userscripts",
vi: "Tìm Userscripts",
Expand All @@ -10,9 +10,6 @@ export default {
},

onClickExtension: function () {
let search = prompt("Search for Userscripts:", "");
if (search != null) {
window.open("https://www.userscript.zone/search?q=" + search);
}
window.open("https://www.userscript.zone/");
},
};
6 changes: 5 additions & 1 deletion scripts/youtube_downloadVideo.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,17 @@ export default {
}

let options = [
{
name: "y2mate.com",
func: (url) => url.replace("youtube.com", "youtubepp.com"),
},
{
name: "yt1s.com",
func: (url) => "https://yt1s.com/vi/youtube-to-mp4?q=" + url,
},
{
name: "yt5s.com",
func: (url) => url.replace("youtube", "youtube5s"),
func: (url) => url.replace("youtube.com", "youtube5s.com"),
},
{
name: "tubemp3.to",
Expand Down
66 changes: 34 additions & 32 deletions scripts/zingmp3_downloadMusic.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export default {
return sig;
},

requestZing: async ({ path, qs, willHashParam }) => {
requestZing: async ({ path, qs, willHashParam, host = URL_API }) => {
let param = new URLSearchParams(qs).toString();
let sig = await Utils.hashParam(path, param, willHashParam);

Expand All @@ -73,7 +73,7 @@ export default {
sig,
};

return URL_API + path + "?" + new URLSearchParams(params).toString();
return host + path + "?" + new URLSearchParams(params).toString();
},
};

Expand Down Expand Up @@ -134,6 +134,19 @@ export default {
willHashParam: false,
});
},
async downloadSong(id) {
return await Utils.requestZing({
host: "https://download.zingmp3.vn",
path: "/api/v2/download/post/song",
qs: { id },
});
},
async getLyric(id) {
return await Utils.requestZing({
path: "/api/v2/lyric/get/lyric",
qs: { id },
});
},
//#endregion

//#region other APIs
Expand Down Expand Up @@ -202,44 +215,33 @@ export default {
qs: { page },
});
},
// async getUserListSong({
// type = "library",
// page = 1,
// count = 50,
// sectionId = "mFavSong",
// } = {}) {
// return await Utils.requestZing({
// path: "/api/v2/user/song/get/list",
// qs: { type, page, count, sectionId },
// // willHashParam: false,
// });
// },
// async getSectionPlaylist(id) {
// return await Utils.requestZing({
// path: "/api/v2/playlist/getSectionBottom",
// qs: { id },
// });
// },
// async getLastPlaying() {
// return await Utils.requestZing({
// path: "/api/v2/user/lasplaying/get/lasplaying",
// });
// },
async getLastPlaying() {
return await Utils.requestZing({
path: "/api/v2/user/lasplaying/get/lasplaying",
});
},
//#endregion
};

(async function () {
// window.open(await ZingMp3.search("game thủ liên minh"));
// window.open(await ZingMp3.getLastPlaying());
// window.open(await ZingMp3.getHome());
// window.open(await ZingMp3.getChartHome());
// window.open(await ZingMp3.getInfoMusic("ZWFE8OUO"));
// window.open(await ZingMp3.getStreaming("Z6WZD78I"));
// window.open(await ZingMp3.getLyric("ZZDEZ8UC"));
// window.open(await ZingMp3.getInfoMusic("ZZDEZ8UC"));
// window.open(await ZingMp3.getStreaming("ZZDEZ8UC"));
// window.open(await ZingMp3.search("game thủ liên minh"));
// window.open(await ZingMp3.getUserMusicOverview());
// window.open(await ZingMp3.getDetailPlaylist("Z6CZOIWU"));
// window.open(await ZingMp3.getDetailArtist("ICM"));

// window.open(await ZingMp3.getChartHome()); // => die
// window.open(await ZingMp3.getLastPlaying()); // => not working?
// window.open(await ZingMp3.downloadSong("Z7ZCD9BD")); // => some songs be blocked on pc
// return;

const tab = await getCurrentTab();
let url = prompt("Nhap link bai hat: ", tab.url);
let url = prompt("Nhập link hoặc id bài hát: ", tab.url);
if (url) {
let songid = ZingMp3.getSongIdFromURL(url);
let songid = url.length > 10 ? ZingMp3.getSongIdFromURL(url) : url;
if (songid) {
try {
const streamUrl = await ZingMp3.getStreaming(songid);
Expand Down

0 comments on commit 7b14c32

Please sign in to comment.