ÙØ«Ø§Ø¦Ù ÙØ§Ø¬ÙØ© Ø§ÙØ¨Ø±Ù جة
ÙØ¸Ø±Ø© عا٠ةâ
تعرÙÙØ§Øª ÙØ§Ø¬Ùات Ø§ÙØ¨Ø±Ù
جة ÙÙØ°Ù Ø§ÙØ¥Ø¶Ø§ÙØ© Ù
بÙÙØ© عÙÙ ÙØ«Ø§Ø¦Ù Tampermonkey. بسبب ÙÙÙØ¯ اÙÙÙØª ÙØ§ÙØ¬ÙØ¯Ø تÙ
تÙÙÙØ° جزء ÙÙØ· Ù
Ù ÙØ§Ø¬Ùات Ø§ÙØ¨Ø±Ù
جة ØØªÙ Ø§ÙØ¢ÙØ ÙØ³ÙستÙ
ر Ø§ÙØªØ·ÙÙØ±. Ø£Ù ÙØ§Ø¬ÙØ© برÙ
جة ØªÙØ³Ø¹Ùا ÙØ°Ù Ø§ÙØ¥Ø¶Ø§ÙØ© أ٠تختÙÙ Ø¹Ù ÙØ§Ø¬ÙØ© GM Ø§ÙØ£ØµÙÙØ© Ù
Ù
ÙØ²Ø© بشÙ٠خاص Ù٠اÙÙØ«Ø§Ø¦Ù (باستخداÙ
*). تÙÙØ± بعض ÙØ§Ø¬Ùات Ø§ÙØ¨Ø±Ù
جة Ø£ÙØ¶Ø§Ù ÙØ¸Ùرا٠بأسÙÙØ¨ Ù
تزاÙ
٠باتباع اÙÙØ§Ø¹Ø¯Ø© GM.* â Ø±Ø§Ø¬Ø¹ Ù
ØØªÙ٠اÙÙØ«Ø§Ø¦Ù ÙÙØªÙاصÙÙ.
ÙÙØØµÙ٠عÙ٠تعرÙÙØ§Øª ÙØ§Ø¬Ùات Ø§ÙØ¨Ø±Ù
جة Ø§ÙØªÙصÙÙÙØ©Ø راجع scriptcat.d.ts أ٠تÙÙ
ÙØØ§Øª اÙÙ
ØØ±Ø± اÙÙ
دÙ
Ø¬Ø©Ø ÙÙØ¯ ÙØ§ تÙÙ٠اÙÙØ«Ø§Ø¦Ù Ù
ØØ¯Ø«Ø© دائÙ
اÙ. ÙÙØ§Ø¬Ùات Ø§ÙØ¨Ø±Ù
جة Ø§ÙØ®Ø§ØµØ© Ø¨ÙØ°Ù Ø§ÙØ¥Ø¶Ø§ÙØ©Ø Ø±Ø§Ø¬Ø¹ ÙØ«Ø§Ø¦Ù CatApi.
ÙÙ ÙÙÙ Ø£ÙØ¶Ø§Ù Ø§ÙØ¹Ø«Ùر عÙÙ Ø£Ù Ø«ÙØ© ذات ØµÙØ© Ù٠دÙÙÙ Ø§ÙØ£Ù Ø«ÙØ©.
Ø§ÙØªØ¹Ø±ÙÙØ§Øªâ
GM_infoâ
ÙØØµÙ Ø¹ÙÙ Ù
عÙÙÙ
ات Ø¹Ù Ø§ÙØ³ÙØ±Ù¾ØªØ Ø¨Ù
ا Ù٠ذÙÙ Ø§ÙØ¨ÙØ§ÙØ§Øª اÙÙØµÙÙØ© ÙÙ
عÙÙ
ات Ø¨ÙØ¦Ø© Ø§ÙØªØ´ØºÙÙ. تتضÙ
Ù Ø§ÙØÙÙÙ Ø§ÙØ´Ø§Ø¦Ø¹Ø© scriptHandler Ù version Ù scriptMetaStr Ù scriptUpdateURL Ù downloadMode ÙØ§ÙÙ
Ø²ÙØ¯. راجع scriptcat.d.ts ÙÙØªØ¹Ø±ÙÙ Ø§ÙØªÙصÙÙÙ (ÙØ¥Ù ÙÙ
ÙÙ٠شاÙ
ÙØ§Ù).
console.log(GM_info.scriptHandler);
console.log(GM_info.version);
console.log(GM_info.scriptMetaStr);
sandboxModeØØ§ÙÙØ§Ù Ù٠اÙÙÙÙ Ø©rawÙÙØ·.runAtØºÙØ± ٠دعÙÙ .userAgentData٠دعÙÙ Ø ÙÙÙÙ ÙØ¯ ÙØ§ ÙØ·Ø§Ø¨Ù Tampermonkey ت٠ا٠اÙ.
GM_log *â
Ø¯Ø§ÙØ© تسجÙÙ. ÙÙ
Ù٠عرض Ø³Ø¬ÙØ§Øª Ø³ÙØ±Ù¾Øª Ø§ÙØ®ÙÙÙØ© ÙÙ Ø³Ø¬Ù Ø§ÙØªØ´ØºÙÙ ÙÙ ÙÙØØ© Ø§ÙØªØÙÙ
(اÙÙØ± عÙ٠عÙ
ÙØ¯ ØØ§ÙØ© Ø§ÙØªØ´ØºÙÙ). Ù
ÙØ§Ø±ÙØ© ب٠TampermonkeyØ ØªÙ
ت Ø¥Ø¶Ø§ÙØ© level ÙÙØ³Ø¬Ù.
declare function GM_log(message: string, level?: GMTypes.LoggerLevel): void;
declare namespace GMTypes {
type LoggerLevel = "debug" | "info" | "warn" | "error";
}
GM_log("debug info", "debug");
GM_get/set/deleteValueâ
ÙØØµÙ Ø£Ù ÙØ¶Ø¨Ø· ÙÙÙ Ø© ÙÙ Ø§ÙØªØ®Ø²ÙÙ. ÙÙ ÙÙ Ù Ø´Ø§Ø±ÙØ© Ø§ÙØ¨ÙØ§ÙØ§Øª ØªØØª ÙÙØ³ storageName ÙÙ Ø²Ø§Ù ÙØªÙا Ù٠اÙÙÙØª اÙÙØ¹ÙÙ.
// Add data â note that data can only be one of bool/string/number/object; you cannot store a class instance
declare function GM_setValue(name: string, value: any): void;
// Get data
declare function GM_getValue(name: string, defaultValue?: any): any | undefined;
// Delete data; getting it again returns undefined or defaultValue
declare function GM_deleteValue(name: string): void;
GM_setValue("foo", 42);
const v = GM_getValue("foo", 0);
GM_deleteValue("foo");
Ù
ÙØ§ØØ¸Ø©: Ø¹ÙØ¯ استدعاء GM_setValue بÙÙÙ
Ø© undefinedØ ÙØØ°Ù ScriptCat ÙØ°Ø§ اÙÙ
ÙØªØ§ØØ عÙÙ Ø¹ÙØ³ Tampermonkey/GreaseMonkey Ø§ÙØ°Ù ÙØ®Ø²Ù undefined ÙÙÙÙ
Ø©.â
Ù
ÙØ§ØØ¸Ø©: ÙØ¸Ø±Ø§Ù ÙØ£Ù عÙ
ÙÙØ§Øª Ø§ÙØ¨ÙØ§ÙØ§Øª ØºÙØ± Ù
تزاÙ
ÙØ©Ø ÙØ¥Ù استدعاء window.close() ÙÙØ±Ø§Ù بعد GM_setValue Ø£Ù GM_deleteValue ÙØ¯ ÙÙ
ÙØ¹ ØªØØ¯ÙØ« Ø§ÙØ¨ÙØ§ÙØ§Øª بشÙ٠صØÙØ. ÙÙÙØµØ باستخداÙ
await GM.setValue Ø£Ù await GM.deleteValue ÙØ¶Ù
Ø§Ù Ø§ÙØªÙ
ا٠عÙ
ÙÙØ© Ø§ÙØ¨ÙØ§ÙØ§Øª.â
GM_listValuesâ
ÙØ³Ø±Ø¯ Ø¬Ù ÙØ¹ اÙÙ ÙØ§ØªÙØ.
declare function GM_listValues(): string[];
console.log(GM_listValues());
GM_setValues / GM_getValues / GM_deleteValues *â
ÙØ§Ø¬Ùات بر٠جة ÙÙØØµÙÙ/Ø§ÙØ¶Ø¨Ø· Ø¨Ø§ÙØ¬Ù ÙØ© (ا٠تداد).
// Sets multiple values; values is an object whose keys are the value names and whose values are the value contents
declare function GM_setValues(values: { [key: string]: any }): void;
// Gets multiple values; if keysOrDefaults is an object, its values are used as the defaults
declare function GM_getValues(keysOrDefaults: { [key: string]: any } | string[] | null | undefined): { [key: string]: any };
// Deletes multiple values; names is an array of strings
declare function GM_deleteValues(names: string[]): void;
// Batch set
GM_setValues({ a: 1, b: 2 });
// Batch get (returns the default if not present)
const { a, b, c = 3 } = GM_getValues({ a: 0, b: 0, c: 3 });
// Batch delete
GM_deleteValues(["a", "b"]);
Ù
ÙØ§ØØ¸Ø©: ÙØ¸Ø±Ø§Ù ÙØ£Ù عÙ
ÙÙØ§Øª Ø§ÙØ¨ÙØ§ÙØ§Øª ØºÙØ± Ù
تزاÙ
ÙØ©Ø ÙØ¥Ù استدعاء window.close() ÙÙØ±Ø§Ù بعد GM_setValues Ø£Ù GM_deleteValues ÙØ¯ ÙÙ
ÙØ¹ ØªØØ¯ÙØ« Ø§ÙØ¨ÙØ§ÙØ§Øª بشÙ٠صØÙØ. ÙÙÙØµØ باستخداÙ
await GM.setValues Ø£Ù await GM.deleteValues ÙØ¶Ù
Ø§Ù Ø§ÙØªÙ
ا٠عÙ
ÙÙØ© Ø§ÙØ¨ÙØ§ÙØ§Øª.â
GM_add/removeValueChangeListenerâ
ت٠ت Ø¥Ø²Ø§ÙØ©
tabidبعد 0.17.0-alpha â Ø±Ø§Ø¬Ø¹ GM_cookie ÙÙØªÙاصÙÙ.
ÙØ³ØªÙ
ع ÙØªØºÙÙØ±Ø§Øª ÙÙÙ
Ø©. add ÙØ¹Ùد Ù
عر٠Ù
ستÙ
Ø¹Ø ÙÙÙ
Ù٠استخداÙ
remove ÙØ¥Ùغاء اÙÙ
ستÙ
ع. ÙÙ
Ù٠استخداÙ
ÙØ°Ù Ø§ÙØ·Ø±ÙÙØ© ÙØªÙÙÙØ° ØªÙØ§ØµÙ Ø¨Ø³ÙØ·Ø باستخداÙ
storageName ÙÙ
Ù٠تØÙÙÙ Ø§ÙØªÙاص٠بÙÙ Ø§ÙØ³Ùرپتات.
// tabid is only present when listening from a background script
type ValueChangeListener = (
name: string,
oldValue: any,
newValue: any,
remote: boolean,
tabid?: number
) => any;
declare function GM_addValueChangeListener(
name: string,
listener: GMTypes.ValueChangeListener
): number;
declare function GM_removeValueChangeListener(listenerId: number): void;
const id = GM_addValueChangeListener("foo", (k, oldV, newV, remote) => {
console.log(k, oldV, newV, remote);
});
GM_removeValueChangeListener(id);
GM_getResourceText/GM_getResourceURLâ
ÙØØµÙ Ø¹ÙÙ Ù
عÙÙÙ
ات اÙÙ
ÙØ±Ø¯ اÙÙ
ØµØ±Ø Ø¨ÙØ§ ب٠@resource.
// GM_getResourceText gets the resource's text data; byte-type data such as images returns an empty string â use GM_getResourceURL for those instead
declare function GM_getResourceText(name: string): string | undefined;
// GM_getResourceURL gets base64-encoded data; a blob URL can also be obtained via the second parameter
declare function GM_getResourceURL(name: string, isBlobUrl?: boolean): string | undefined;
const css = GM_getResourceText("mystyle");
const imgUrl = GM_getResourceURL("logo");
GM_addElementâ
ÙØ¯Ø±Ø¬ Ø¹ÙØµØ±Ø§Ù ÙÙ Ø§ÙØµÙØØ©. ÙÙ ÙÙÙ ØªØ¬Ø§ÙØ² ÙÙÙØ¯ CSP.
declare function GM_addElement(tag: string, attributes: any): HTMLElement;
declare function GM_addElement(parentNode: Element, tag: string, attrs: any): HTMLElement;
// Insert a script
GM_addElement("script", { src: "https://example.com/app.js" });
// Insert a style
GM_addElement(document.head, "style", { textContent: ".foo{color:blue}" });
GM_addStyleâ
ÙØ¶ÙÙ Ù٠طا٠إÙÙ Ø§ÙØµÙØØ© ÙÙØ¹Ùد Ø¹ÙØ¯Ø© ÙÙ Ø· DOM. ÙÙ ÙÙÙ ØªØ¬Ø§ÙØ² ÙÙÙØ¯ CSP.
declare function GM_addStyle(css: string): HTMLElement;
GM_addStyle(`
body { background: #f0f0f0; }
.btn { color: red; }
`);
GM_openInTab *â
ÙÙØªØ ÙØ§Ùذة Ø¬Ø¯ÙØ¯Ø©.
declare function GM_openInTab(url: string, options: GMTypes.OpenTabOptions): GMTypes.Tab;
declare function GM_openInTab(url: string, loadInBackground: boolean): GMTypes.Tab;
declare function GM_openInTab(url: string): GMTypes.Tab;
declare namespace GMTypes {
interface OpenTabOptions {
/**
* Determines whether the new tab gets focus when opened.
*
* - `true` â the new tab is immediately switched to the foreground.
* - `false` â the new tab opens in the background, without stealing focus from the current page.
*
* Default: true
*/
active?: boolean;
/**
* Determines where the new tab is inserted.
*
* - If a `boolean`:
* - `true` â inserted right after the current tab.
* - `false` â inserted at the end of the window.
* - If a `number`:
* - `0` â inserted one position before the current tab.
* - `1` â inserted one position after the current tab.
*
* Default: true
*/
insert?: boolean | number;
/**
* Determines whether the parent tab (i.e. `openerTabId`) is set.
*
* - `true` â the browser can track which tab opened the child tab,
* which helps some extensions (like tab-tree managers) identify parent/child relationships.
*
* Default: true
*/
setParent?: boolean;
/**
* Whether to open the tab in a private (incognito) window.
*
* Note: ScriptCat's manifest.json sets `"incognito": "split"`,
* so when running in a normal window, tabId/windowId will not be
* available, and only the "open a new tab" action can be performed.
*
* Default: false
*/
incognito?: boolean;
/**
* Legacy compatibility field, supported only by Tampermonkey.
* Its meaning is the **opposite** of `active`:
*
* - `true` â equivalent to `active = false` (loads in the background).
* - `false` â equivalent to `active = true` (loads in the foreground).
*
* â ï¸ Not recommended: overlaps with `active` and is easy to confuse.
*
* Default: false
* @deprecated Use `active` instead
*/
loadInBackground?: boolean;
/**
* Whether to pin the new tab to the left side of the browser's tab bar.
*
* - `true` â the new tab is pinned.
* - `false` â a regular tab.
*
* Default: false
*/
pinned?: boolean;
/**
* Uses `window.open` to open the new tab instead of `chrome.tabs.create`.
* Useful when opening links with certain special protocols, e.g. `vscode://`, `m3u8dl://`.
* Other parameters have no effect when using this open method.
*
* Related: Issue #178 #1043
* Default: false
*/
useOpen?: boolean;
}
interface Tab {
close(): void;
onclose?: () => void;
closed?: boolean;
name?: string;
}
}
const tab = GM_openInTab("https://example.com", { active: false });
tab.onclose = () => console.log("closed");
tab.close();
GM_closeInTabâ
Ø¥ØºÙØ§Ù تبÙÙØ¨ ÙÙØªØ Ø¨ÙØ§Ø³Ø·Ø© GM_openInTab.
declare function GM_closeInTab(tabId: string): void;
GM_get/saveTab/GM_getTabsâ
طرÙÙØ© ÙØªØ®Ø²ÙÙ Ø§ÙØ¨ÙØ§ÙØ§Øª تشب٠GM_setValueØ ÙÙÙ Ø¯ÙØ±Ø© ØÙاة ÙØ°Ù Ø§ÙØ·Ø±ÙÙØ© Ù
رتبطة Ø¨Ø¯ÙØ±Ø© ÙØªØâØ¥ØºÙØ§Ù تبÙÙØ¨ Ù
ØªØµÙØ ÙØ§ØØ¯Ø ÙÙØ§ ÙÙ
Ù٠استخداÙ
ÙØ§ Ù
Ù Ø³ÙØ±Ù¾Øª Ø®ÙÙÙØ©.
// Get tab data
declare function GM_getTab(callback: (obj: object) => void): void;
// Save tab data
declare function GM_saveTab(obj: object): void;
// Get all tabs' data
declare function GM_getTabs(callback: (objs: { [key: number]: object }) => void): void;
GM_saveTab({ foo: 1 }, () => console.log("saved"));
GM_getTab(tab => console.log(tab));
GM_getTabs(tabs => console.log(tabs));
GM_registerMenuCommand *â
- ÙØ³Ø¬Ù Ø¹ÙØµØ± ÙØ§Ø¦Ù
Ø© ÙØ¸Ùر ÙÙ Ø§ÙØµÙØØ© اÙÙ
ÙØ¨Ø«ÙØ© ÙÙØ§Ø¦Ù
Ø© اÙÙÙØ± بزر اÙÙ
Ø§ÙØ³ Ø§ÙØ£ÙÙ
ÙØ اÙÙÙØ± عÙÙÙ ÙØ³ØªØ¯Ø¹Ù Ø¯Ø§ÙØ©
listener. - Ø§ÙØªØ±Ø§Ø¶ÙØ§ÙØ Ù Ø·Ø§Ø¨ÙØ©Ù ÙÙ TampermonkeyØ ØªØ¸ÙØ± Ø¹ÙØ§ØµØ± اÙÙØ§Ø¦Ù Ø© Ø§ÙØªÙ تØÙ Ù ÙÙØ³ اÙÙØµ اÙÙ Ø¹Ø±ÙØ¶ ٠رة ÙØ§ØØ¯Ø© ÙÙØ·.
- ØªØØ¯Ùد
idÙØªÙØ ÙÙ ØªØØ¯ÙØ« Ø¹ÙØµØ± اÙÙØ§Ø¦Ù Ø©. - إذا ÙØ§Ùت
nameØ³ÙØ³ÙØ© ÙØ§Ø±ØºØ© ÙÙØ§ ÙÙØ¬Ø¯listenerØ ØªØªÙ Ø¥Ø¶Ø§ÙØ© خط ÙØ§ØµÙ Ø¥ÙÙ ÙØ§Ø¦Ù Ø© اÙÙÙØ± بزر اÙÙ Ø§ÙØ³ Ø§ÙØ£ÙÙ Ù.
function GM_registerMenuCommand(
name: string,
listener?: (inputValue?: any) => void,
options_or_accessKey?:
| {
id?: number | string;
accessKey?: string;
autoClose?: boolean; // ScriptCat-specific option; defaults to true, and false keeps the popup menu page open after clicking
nested?: boolean; // ScriptCat-specific option; defaults to true, and false raises the browser's right-click menu item from a third-level to a second-level menu
individual?: boolean; // ScriptCat-specific option; defaults to false, and true means identical menu items are not merged together
}
| string
): number;
const cmdId = GM_registerMenuCommand("Test Command 01", () => alert("Called 01"));
GM_registerMenuCommand("Test Command 02", () => alert("Called 02"), {id: "custom-id"});
GM_unregisterMenuCommandâ
ÙØ²ÙÙ Ø¹ÙØµØ± ÙØ§Ø¦Ù Ø© Ù Ø³Ø¬ÙØ§Ù ØØ³Ø¨ ٠عرÙÙ.
declare function GM_unregisterMenuCommand(id: number): void;
GM_unregisterMenuCommand(cmdId);
GM_unregisterMenuCommand("custom-id");
GM_notification *â
ÙØ±Ø³Ù Ø±Ø³Ø§ÙØ© Ø¥Ø´Ø¹Ø§Ø±Ø ÙÙÙÙØ± Ø¥Ù
ÙØ§ÙÙØ§Øª progress Ù buttons (ØºÙØ± Ù
دعÙÙ
Ø© ÙÙ Firefox)Ø Ø¨ØÙØ« ÙÙ
ÙÙ ÙÙØ¥Ø´Ø¹Ø§Ø± عرض Ø´Ø±ÙØ· ØªÙØ¯Ù
أ٠أزرار. ÙÙÙØ± Ø£ÙØ¶Ø§Ù طرÙÙØªÙ٠إضاÙÙØªÙÙØ GM_closeNotification Ù GM_updateNotification (ØºÙØ± Ù
دعÙÙ
تÙÙ ÙÙ Firefox).
declare function GM_notification(
details: GMTypes.NotificationDetails,
ondone?: GMTypes.NotificationOnDone
): void;
declare function GM_notification(
text: string,
title: string,
image: string,
onclick: GMTypes.NotificationOnClick
): void;
declare function GM_closeNotification(id: string): void;
declare function GM_updateNotification(id: string, details: GMTypes.NotificationDetails): void;
declare namespace GMTypes {
interface NotificationDetails {
text?: string;
title?: string;
tag?: string;
image?: string;
highlight?: boolean;
silent?: boolean;
timeout?: number;
url?: string;
onclick?: NotificationOnClick;
ondone?: NotificationOnDone;
progress?: number;
oncreate?: NotificationOnClick;
// At most 2 can exist
buttons?: NotificationButton[];
}
interface NotificationThis extends NotificationDetails {
id: string;
}
type NotificationOnClickEvent = {
event: "click" | "buttonClick";
id: string;
isButtonClick: boolean;
buttonClickIndex: number | undefined;
byUser: boolean | undefined;
preventDefault: () => void;
highlight: NotificationDetails["highlight"];
image: NotificationDetails["image"];
silent: NotificationDetails["silent"];
tag: NotificationDetails["tag"];
text: NotificationDetails["tag"];
timeout: NotificationDetails["timeout"];
title: NotificationDetails["title"];
url: NotificationDetails["url"];
};
type NotificationOnClick = (this: NotificationThis, event: NotificationOnClickEvent) => unknown;
type NotificationOnDone = (this: NotificationThis, user?: boolean) => unknown;
interface NotificationButton {
title: string;
iconUrl?: string;
}
}
GM_notification({ title: "Progress", text: "Loading", progress: 50 });
Ù
ÙØ§ØØ¸Ø©: GM_closeNotification Ù GM_updateNotification خاصتا٠ب٠ScriptCat. ÙØªØØ¯ÙØ« Ø¥Ø´Ø¹Ø§Ø±Ø Ø§Ø³ØªØ®Ø¯Ù
tag.â
GM_notification({ title: "Progress", text: "Loading", progress: 50, tag: "notification01"});
GM_notification({ title: "Progress", text: "Done", progress: 100, tag: "notification01"}); // updates the progress
GM_notification({ title: "Progress", text: "Done", progress: 100, tag: "notification01", timeout: 1}); // closes after 1ms
GM_setClipboard *â
ÙØ¶Ø¨Ø· Ø§ÙØØ§ÙØ¸Ø©. ÙØ§ ÙÙØ¯Ø¹Ù Ø§ÙØ§Ø³ØªØ¯Ø¹Ø§Ø¡ Ø§ÙØ±Ø¬Ø¹Ù Ø¨Ø¹Ø¯Ø Ø¹ÙÙ Ø¹ÙØ³ Tampermonkey.
declare function GM_setClipboard(
data: string,
info?: string | { type?: string; mimetype?: string }
): void;
GM_setClipboard("Hello World", "text");
GM_xmlhttpRequest *â
-
Ø·ÙØ¨ HTTP عبر اÙÙØ·Ø§Ùات ÙÙ ÙÙÙ ØªØ¬Ø§ÙØ² CSPØ ÙÙØ¯Ø¹Ù اÙÙØ·Ø§Ùات اÙÙ ØµØ±Ø Ø¨ÙØ§ بÙ
@connect. بعض اÙÙØ¸Ø§Ø¦Ù Ù ÙÙÙØ¯Ø©Ø Ù ÙØ²Ø© اÙÙÙÙÙØ² ØºÙØ± ٠دعÙÙ Ø© ØØ§ÙÙØ§Ù ÙÙ Firefox. إذ٠اÙ٠ستخد٠٠طÙÙØ¨ ÙÙÙØµÙÙ Ø§ÙØ¹Ø§Ø¯ÙØ Ø§Ù٠ضÙ٠اÙÙ ÙØµÙÙ Ø¨ÙØ§Ø³Ø·Ø©@connectÙÙ ÙÙ٠تخط٠إذ٠اÙ٠ستخد٠. -
ÙØªÙ Ø§ÙØªØ¹Ø§Ù ٠٠ع
anonymousÙcookieبشÙ٠٠ختÙ٠ع٠Tampermonkey: Ø¹ÙØ¯Ù ا ÙÙÙÙanonymousصØÙØØ§Ù ÙØªÙجدcookieØ ÙØªÙ إرسا٠اÙÙÙÙ٠اÙÙ ØØ¯Ø¯Ø© ÙÙØ·Ø دÙÙ Ø¥Ø±ÙØ§Ù Ø£Ù ÙÙÙÙØ² أخرÙ. -
Ù٠ا ØªØ¯Ø¹Ù Ø§ÙØªØ±ÙÙØ³Ø§Øª Ø§ÙØ®Ø§ØµØ©:
- user-agent
- origin
- referer
- cookie
- host
- ...
declare function GM_xmlhttpRequest(details: GMTypes.XHRDetails): GMTypes.AbortHandle<void>;
declare namespace GMTypes {
interface XHRResponse {
finalUrl?: string;
readyState?: 0 | 1 | 2 | 3 | 4;
responseHeaders?: string;
status?: number;
statusText?: string;
response?: any;
responseText?: string;
responseXML?: Document | null;
}
interface XHRProgress extends XHRResponse {
done: number;
lengthComputable: boolean;
loaded: number;
position: number;
total: number;
totalSize: number;
}
type Listener<OBJ> = (event: OBJ) => any;
interface XHRDetails {
method?: "GET" | "HEAD" | "POST" | "PUT" | "DELETE" | "PATCH" | "OPTIONS";
url: string;
headers?: { [key: string]: string };
data?: string | FormData;
cookie?: string;
binary?: boolean;
timeout?: number;
responseType?: "text" | "arraybuffer" | "blob" | "json" | "document" | "stream"; // stream is a fairly basic implementation in the current version
overrideMimeType?: string;
anonymous?: boolean;
fetch?: boolean;
user?: string;
password?: string;
nocache?: boolean;
redirect?: "follow" | "error" | "manual"; // to stay consistent with Tampermonkey, maxRedirects was deprecated after v0.17.0 in favor of redirect, which forces fetch mode
onload?: Listener<XHRResponse>;
onloadstart?: Listener<XHRResponse>;
onloadend?: Listener<XHRResponse>;
onprogress?: Listener<XHRProgress>;
onreadystatechange?: Listener<XHRResponse>;
ontimeout?: () => void;
onabort?: () => void;
onerror?: (err: string) => void;
}
}
GM_xmlhttpRequest({
method: "GET",
url: "https://api.example.com/data",
onload: res => console.log(res.responseText)
});
GM_downloadâ
- ÙÙØ²ÙÙ Ù
ÙÙØ§ÙØ Ù
ع Ø¥Ù
ÙØ§ÙÙØ© تÙÙÙÙ Ø§ÙØªØ±ÙÙØ³Ø§Øª ÙØ®Ùارات Ø£Ø®Ø±ÙØ Ù
ÙØ§Ø±ÙØ© ب٠Tampermonkey ÙØ¯Ø¹Ù
Ø£ÙØ¶Ø§Ù Ø®ÙØ§Ø±Ù cookie Ù anonymous. إذا Ø£ÙØ¹Ø·Ù عÙÙØ§Ù URL ÙÙ blobØ ÙØ¥ÙÙ ÙÙØªØ Ø§ÙØªÙزÙÙ Ù
باشرة ÙÙØ§ ÙØ·Ù٠سÙÙ ØØ¯Ø«
onloadâ ÙÙØ°Ø§ ÙØ®ØªÙ٠ع٠Tampermonkey ÙÙÙØ¬Ø¯ ÙØ¯Ø¹Ù Ø³ÙØ±Ù¾ØªØ§Øª Ø§ÙØ®ÙÙÙØ©Ø Ø§ÙØªÙ ÙØ§ ÙÙ ÙÙÙØ§ Ø¨Ø®ÙØ§Ù ذÙÙ Ø¥ÙØ´Ø§Ø¡ ØªÙØ²ÙÙ (Ù ÙÙØ¯ ÙØ³ÙÙØ§Ø±ÙÙÙØ§Øª Ù Ø«Ù Ø¥ÙØ´Ø§Ø¡ Ø§ÙØªÙØ§Ø±ÙØ±). - ÙØ¹Ùد ÙØ§Ø¦Ù Promise ÙÙÙÙØ± طرÙÙØ©
abort(). - عÙÙ Ø¹ÙØ³ TampermonkeyØ ÙØ¥Ù ÙØ¶Ø¹ ØªÙØ²ÙÙ
nativeÙÙ ScriptCat (Ø§ÙØ§ÙتراضÙ) ÙØØªØ±Ù@connect: Ø¹ÙØ¯Ù ا ÙØ§ ÙÙÙ٠٠ضÙ٠عÙÙØ§Ù Ø§ÙØªÙزÙÙ Ù ØºØ·Ù Ø¨ØªØµØ±ÙØØ§Øª@connectØ§ÙØ®Ø§ØµØ© Ø¨Ø§ÙØ³ÙØ±Ù¾ØªØ ÙØ·Ùب ScriptCat ٠٠اÙÙ Ø³ØªØ®Ø¯Ù Ø§ÙØªØ£ÙÙØ¯ ÙØ¨Ù Ø§ÙØªÙزÙÙØ اÙ٠ضÙÙØ§Øª اÙ٠غطاة بÙ@connectتÙÙØ²ÙÙÙ Ø¨ØµÙ ØªØ ÙØ§Ù٠ضÙÙØ§Øª Ù٠اÙÙØ§Ø¦Ù Ø© Ø§ÙØ³Ùداء ØªÙØ±Ùض دائ٠اÙ. ÙØ¶Ø¹ Ø§ÙØªÙزÙÙbrowserÙØ§ ÙØ®Ø¶Ø¹ ÙÙØ°Ø§ اÙÙØØµ. (ÙÙ TampermonkeyØ ÙÙØ·Ø¨Ù@connectÙÙØ· عÙÙGM_xmlhttpRequestØ ÙÙÙØ³GM_download.)
declare function GM_download(details: GMTypes.DownloadDetails): GMTypes.AbortHandle<boolean>;
declare function GM_download(url: string, filename: string): GMTypes.AbortHandle<boolean>;
declare namespace GMTypes {
interface DownloadError {
error:
| "not_enabled"
| "not_whitelisted"
| "not_permitted"
| "not_supported"
| "not_succeeded"
| "unknown";
details?: string;
}
interface DownloadDetails {
method?: "GET" | "POST";
downloadMode?: "native" | "browser";
url: string;
name: string;
headers?: { [key: string]: string };
saveAs?: boolean;
timeout?: number;
cookie?: string;
anonymous?: boolean;
onerror?: Listener<DownloadError>;
ontimeout?: () => void;
onload?: Listener<object>;
onprogress?: Listener<XHRProgress>;
}
}
// Callback form
const dl = GM_download({ url: "https://example.com/file.zip", name: "file.zip", onload: () => alert("Done") });
dl.abort();
GM_cookie *â
ÙØ¹Ù ٠بشÙÙ ØºÙØ± ٠تزا٠٠عÙÙ ÙÙÙÙØ² Ø§ÙØµÙØØ©Ø ÙÙØ¯Ø¹Ù عبر اÙÙØ·Ø§Ùات Ù HttpOnly Ù partitioned cookies.
بعد v0.17.0-alphaØ ØªÙ Øª Ø¥Ø²Ø§ÙØ© اÙ٠عÙ٠ات اÙ٠تعÙÙØ© بÙ
storeÙtabidØ ÙÙØ±Ø± ScriptCat Ø§ÙØ¢Ù ٠ا إذا ÙØ§Ù Ø³ÙØØµÙ Ø¹Ù٠اÙÙÙÙÙØ² Ù Ù ÙØ§Ùذة Ø§ÙØªØµÙØ Ø§ÙØ®Ø§Øµ أ٠اÙÙØ§Ùذة Ø§ÙØ¹Ø§Ø¯ÙØ© Ø¨ÙØ§Ø¡Ù عÙ٠اÙÙØ§Ùذة اÙÙ ÙØ¬Ùدة ÙÙÙØ§ ØØ§ÙÙØ§Ù.
ÙØ¬Ø¨ عÙÙÙ Ø§ÙØªØµØ±ÙØ Ø¹Ù Ø§ÙÙ
ضÙ٠اÙÙ
شغÙÙ٠ب٠@connectØ ÙÙØªØ·Ùب إذ٠اÙÙ
ستخدÙ
ÙÙØ§Ø³ØªØ®Ø¯Ø§Ù
. Ù
ع ÙÙÙÙ Ù
ØªÙØ§ÙÙØ§Ù Ù
ع عÙ
ÙÙØ© GM_cookie.list Ø§ÙØ®Ø§ØµØ© ب٠TampermonkeyØ Ø¥ÙØ§ Ø£ÙÙ ØºÙØ± Ù
ÙØµÙ Ø¨ÙØ Ù
Ù Ø£Ø¬Ù Ø§ÙØ§ØªØ³Ø§Ù.
sameSiteØºÙØ± ٠دعÙÙ .
// name and domain cannot both be empty
declare function GM_cookie(
action: GMTypes.CookieAction,
details: GMTypes.CookieDetails,
ondone: (cookie: GMTypes.Cookie[], error: unknown | undefined) => void
): void;
declare namespace GMTypes {
type CookieAction = "list" | "delete" | "set";
interface CookieDetails {
url?: string;
name?: string;
value?: string;
domain?: string;
path?: string;
secure?: boolean;
session?: boolean;
httpOnly?: boolean;
expirationDate?: number;
partitionKey?: CookieDetailsPartitionKeyType;
}
interface Cookie {
domain: string;
name: string;
value: string;
session: boolean;
hostOnly: boolean;
expirationDate?: number;
path: string;
httpOnly: boolean;
secure: boolean;
}
}
// Callback form
GM_cookie("list", { url: "https://example.com" }, (cookies) => {
console.log(cookies);
GM_cookie("set", {
name: "foo",
value: "bar",
domain: "example.com"
}, (result) => {
console.log(result);
GM_cookie("delete", { name: "foo", domain: "example.com" }, (result) => {
console.log(result);
});
});
});
// Promise form
const cookies = await GM.cookie.list({ url: "https://example.com" });
await GM.cookie.set({ name: "foo", value: "bar", domain: "example.com" });
await GM.cookie.delete("foo", { domain: "example.com" });
Ù
ÙØ§ØØ¸Ø©: ÙØ¬Ø¨ عÙÙÙ Ø§ÙØªØµØ±ÙØ Ø¹Ù Ø§ÙÙØ·Ø§Ù اÙÙ
سÙ
ÙØ ÙÙ Ø§ÙØ¨ÙØ§ÙØ§Øª اÙÙØµÙÙØ© باستخداÙ
@connect example.com.